0

What to do if cmd gives errror: "python: can't open file 'C:\Users\Username\3.9.1': [Errno 2] No such file or directory

(Python 3.9.1) File was compiled with sublime 3

13th Apr 2021, 9:09 PM
Raphael Thikusho II
Raphael Thikusho II - avatar
10 odpowiedzi
+ 3
go to the python script dir and try running the cmd there
13th Apr 2021, 9:19 PM
Hëllo Wörld🔰
Hëllo Wörld🔰 - avatar
+ 3
it means the file doesnt exist. You cant just provide a filename. Wherever your code is being saved is the current working directory. if you want to reference a file, you should provide the full path from root or C drive
14th Apr 2021, 3:23 AM
Slick
Slick - avatar
+ 1
with this command, you should be able to see name of your python file in a list: import os print([i for i in os.listdir() if ".py" in i]) and then you can get full path of your python file with this command: print(os.path.abspath("your_file_name.py"))
15th Apr 2021, 6:16 PM
Tomas Konecny
+ 1
Raphael Thikusho II run this command in your python script
15th Apr 2021, 6:43 PM
Tomas Konecny
+ 1
Is the file called '3.9.1'? If it is actually named '3.9.1.py' you should refer to it as such. Also one should not put dots in filenames unless it is for defining file extensions or such errors appear. Just good programming practice ;)
15th Apr 2021, 8:32 PM
Marius Winkler
Marius Winkler - avatar
+ 1
He can try to use Python IDE and run it there... It should be more error-proof way
16th Apr 2021, 5:30 AM
Tomas Konecny
+ 1
Open cmd as administrator and it will work
2nd Feb 2024, 4:33 PM
O'ktam
O'ktam - avatar
0
Slick When I do it like this I still get the same error
14th Apr 2021, 7:34 AM
Raphael Thikusho II
Raphael Thikusho II - avatar
0
delete the current file and install it agian
15th Apr 2021, 4:49 PM
Rushikesh Shrivastav
Rushikesh Shrivastav - avatar
0
Tomáš Konečný should i do this in the cmd??
15th Apr 2021, 6:41 PM
Raphael Thikusho II
Raphael Thikusho II - avatar