简体   繁体   English

Mac 终端上没有 python 的此类文件或目录

[英]No such file or directory on Mac terminal for python

hello.py is my first python program. hello.py是我的第一个 python 程序。 It is saved on my desktop.它保存在我的桌面上。

In the terminal I write in front of在终端我写在前面

user@AA-MacBook-Air ~ % python3 hello.py

The error is错误是

can't open file 'hello.py': [Errno 2] No such file or directory

Kindly help me understand the problem and solve it.请帮助我理解问题并解决它。

you first need to change destination with cd你首先需要用 cd 改变目的地

The error message, No such file or directory pretty much gives the explanation.错误消息, No such file or directory几乎给出了解释。 Check if the file hello.py is present in the correct working directory.检查文件hello.py是否存在于正确的工作目录中。 This can done graphically or using the ls command.这可以通过图形方式或使用ls命令完成。 If it is not present, copy the file the to the directory or navigate to the location of the file hello.py in terminal using cd .如果不存在,请将文件复制到目录或使用cd导航到终端中文件hello.py的位置。

In the terminal you are currently in the directory ~ .在终端中,您当前位于目录中~ This signifies the folder /Users/<username> .这表示文件夹/Users/<username> Your script is on your desktop.您的脚本在您的桌面上。

Type cd Desktop to change to /Users/<username>/Desktop and then run python3 hello.py .键入cd Desktop以更改为/Users/<username>/Desktop然后运行python3 hello.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM