[英]How to run python using ./ from Linux terminal?
I have a .py python script and when I run it typing ./filename.py
I obtain a syntax error. 我有一个.py python脚本,当我运行它时,键入
./filename.py
出现语法错误。 However, when I run it typing python filename.py
my program executes correctly. 但是,当我运行它键入
python filename.py
我的程序可以正确执行。
How to make it run correctly typing ./filename.py
? 如何通过键入
./filename.py
使它正确运行? I think it is related to the $PATH variable but I don't have any further idea. 我认为它与$ PATH变量有关,但是我没有任何进一步的想法。
put either a shebang at the start of the file, or run with python for example: 将shebang放在文件的开头,或使用python运行,例如:
#!/usr/bin/env python3
or run: 或运行:
python3 filename.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.