bash:python:.py:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47443988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bash: python: .py: command not found
提问by Muhammad Arslan
I am trying to run the following command in QIIME2 virtual machine
, installed on macbook but the code is not working
我正在尝试QIIME2 virtual machine
在 macbook 上运行以下命令,但代码不起作用
validate_mapping_file.py -m Fasting_Map.txt -o mapping_output
Here is the link: http://qiime.org/tutorials/tutorial.html
这是链接:http: //qiime.org/tutorials/tutorial.html
I get the following message
我收到以下消息
bash: validate_mapping_file.py: command not found
bash:validate_mapping_file.py:找不到命令
I am new to unix/linux
as well as on qiime
. I would be very thankful for the help...
我unix/linux
对qiime
. 我将非常感谢您的帮助...
回答by Florian Rhiem
To execute a Python script in this way, you need three things:
要以这种方式执行 Python 脚本,您需要三样东西:
The file needs to have the executable bit set for you. To do this, try using:
chmod u+x validate_mapping_file.py
The file needs to begin with a shebang, for example
#!/usr/bin/env python3
which will tell the system to run the script using the python3 executable according to your environmentThe file needs to be in one of the directories in your
PATH
environment variable. You can add the current directory using exportPATH=$PWD:$PATH
or use./validate_mapping_file.py
instead of justvalidate_mapping_file.py
(thanks @Grisha)
该文件需要为您设置可执行位。为此,请尝试使用:
chmod u+x validate_mapping_file.py
该文件需要以shebang开头,例如
#!/usr/bin/env python3
,它会告诉系统根据您的环境使用python3可执行文件运行脚本该文件需要位于您的
PATH
环境变量中的目录之一中。您可以使用 exportPATH=$PWD:$PATH
或 use./validate_mapping_file.py
而不是添加当前目录validate_mapping_file.py
(感谢@Grisha)
Afterwards you should be able to execute the script the way you tried before.
之后,您应该能够按照之前尝试的方式执行脚本。