无法在term上打开Python脚本

2024-07-07 06:50:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直犯这个错误。我就是不能在终端上打开脚本。我的idle和python控制台正常工作。我不想复制并粘贴行到我的空闲。 我认为python在错误的路径上搜索。。。在

我有ubuntu,请看下面我复制粘贴的终端

judy@ubuntu:~$ cd anotherproject
judy@ubuntu:~/anotherproject$ python hello.py 
python: can't open file 'hello.py': [Errno 2] No such file or directory
judy@ubuntu:~/anotherproject$ cd
judy@ubuntu:~$ cd Scripts
bash: cd: Scripts: No such file or directory
judy@ubuntu:~$ cd Desktop
judy@ubuntu:~/Desktop$ cd Scripts
judy@ubuntu:~/Desktop/Scripts$ python passwordgenerator.py 
python: can't open file 'passwordgenerator.py': [Errno 2] No such file or directory
judy@ubuntu:~/Desktop/Scripts$ ls
gemail.py   hello.py   passwordgenerator.py 
judy@ubuntu:~/Desktop/Scripts$ 

这是我的你好.py文件

^{pr2}$

Tags: ornopyhelloubuntu错误scriptscd
1条回答
网友
1楼 · 发布于 2024-07-07 06:50:47
  1. 在你好.py在~/Desktop/Scripts/中,而不是在~/anotherproject中。尝试python ~/Desktop/Scripts/hello.py
  2. 您可能没有设置正确的权限。python以当前shell用户的身份运行,该用户可能无法读取该文件,因为该文件属于其他用户。尝试输入ls -alh并显示输出。在

相关问题 更多 >