Python錯誤集錦:python: can’t open file ‘hello’: [Errno 2] No such file or directory


錯誤提示:

在命令行輸入python py文件名稱,提示:python: can’t open file ‘hello’: [Errno 2] No such file or directory

D:\juzicode>python hello
python: can't open file 'hello': [Errno 2] No such file or directory

 

可能原因:

1、本意是要用python運行hello.py文件,少寫了后綴,所以提示不能打開hello文件:

2、如果輸入python hello.py 仍提示一樣的內容,需要確認下hello.py是否在當前目錄下,下圖所示的當前目錄是指D:\juzicode。

 

 

解決方法:

1、如果少寫了.py后綴,輸入完整的文件名稱:python hello.py

2、查找hello.py文件的目錄,在cmd命令行切換到py文件的目錄下再運行python hello.py

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM