当我尝试从bash执行python脚本时,权限被拒绝? [英] Permission denied when i try to execute a python script from bash?

查看:116
本文介绍了当我尝试从bash执行python脚本时,权限被拒绝?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从网上下载了一个python脚本,当我尝试从bash执行它时,它抛出了一个异常:

I downloaded a python script from the web and when i try to execute it from bash it throws a exception:

User:python_script user$ ./python_script.py -n some_parameter -b

输出如下:

-bash: ./python_script.py: Permission denied

所有准备就绪的文件在脚本顶部具有:#!/usr/bin/python.我该如何解决?

the file all ready has: #!/usr/bin/python at the top of the script. How can i solve this?

推荐答案

您需要添加执行权限,如下所示:

You need to add execute permissions like so:

chmod u+x python_script.py

这假设脚本是您所有的.如果不是,则可能需要更改组/其他执行权限或相应地chown文件.

This assumes that the script is owned by you. If it isn't, you might need to change the group/other execute permissions or chown the file as appropriate.

这篇关于当我尝试从bash执行python脚本时,权限被拒绝?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆