简体   繁体   中英

Python, unable to open file, Error [2] no such file or directory

I recently started to learn Python using the Google Python Class:

https://developers.google.com/edu/python/

I am using Mac OsX and try to execute a file called hello.py which is part of the tutorial. It is saved in Documents in a folder called Python. Sorrily, if I type python hello.py in the terminal, I receive this:

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

I also tried typing: python ~/Users/sam/Documents/Python/Google and python exercises/google-python-exercises/hello.py , but I have got the same response.

Has anyone got an idea why this error occurs and can help me to solve the problem?

Go into your files, left click on the folder that the file is saved in. Select open in terminal, and in terminal type 'python hello.py'. This works for linux, and may work for mac because of the unix terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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