I created a simple hello world text document named "hello.py" stored in a directory in a drive. I then opened cmd, navigated to the directory where the document was stored, and typed in
py hello.py
And then cmd gives me this error:
C:\Users\nufil\AppData\Local\Programs\Python\Python39\python.exe: can't open file 'D:\Python\hello.py': [Errno 2] No such file or directory
How do I rectify this error and make cmd run my code?
Related
I am trying to access sastrawi folder
The following steps are done
I downloaded the Composer-Setup.exe file from composer page and got successfully installed.
I installed Composer-Setup in sastrawi folder
I get sastrawi folder from https://github.com/sastrawi/sastrawi
I executed the command for accees folder sastrawi in command prompt
php composer.phar require sastrawi/sastrawi:^1
This line generates the error message: could not open file composer.phar
how to resolve this error???
I am running python file from command line. To be more specific my .py file is in location F:\new_github_code\cocktail_party\data\audio\audio_downloader.py>. I want to run audio_downloader.py file from the cocktail_party directory not from the audio directory.
I tried by using the following script from cmd. Any help will be appreciate
enter image description here
Try this. It will work:
python data\audio\audio_downloader.py
I installed Sublime Text 3 notepad to write Python3 and to see the .py files on true location i runned myexample.py (which is on desktop and just printed hello world) on CMD
cd Desktop
python myexample.py
then I got an error message like
python: can't open file 'myexample.py': [Errno 2] No such file or directory
it has to show me only
hello world
on cmd screen instead of that error. What might be wrong here?
I tried to write python3 on cmd, I checked the locations and the myexample.py is on desktop, i even tried to write anaconda to the cmd but couldn't solve it.
python: can't open file 'myexample.py': [Errno 2] No such file or directory
I encountered such a weird situation:
naivechou#naivechou/~>python test.py
test
naivechou#naivechou/~>pwd
/home/naivechou
naivechou#naivechou/~>python /home/naivechou/test.py
C:\toolchain\python\python.exe: can't open file '/home/naivechou/test.py': [Errno 2] No such file or directory
My working directory is /home/naivechou/, test.py is in there.
If I run test.py with absolute path, I'll get an error message of No such file or directory.But everything will be fine if I enter that directory and then run it. What's wrong with python?
Try moving into the folder where the python script is located and do a "ls" command there in Linux. if windows then do 'dir'. if you see the required file there then execute the following command
C:\location_where_the_script_is> python yourfile.py
For commands entered on the command line, Windows doesn't recognize forward-slashes as directory separators.
Your second example is looking in the current directory for the literal filename /home/naivechou/test.py, and of course such a filename does not exist.
Use backslashes instead, as is the Windows way:
python \home\naivechou\test.py
I just installed ubuntu today, and I can't figure out how to run my .py file.
I opened terminal and typed in python test.py and I receive an error saying "python: can't open file 'test.py': [Errno 2] No such file or directory"
If you could please help me out, that would be great.
Thanks
You are using the correct command to open it, but there is no test.py file in your current working directory.
Try using
ls
To verify what files are in fact in your working directory and use
cd path/goes/here
To change directories to where the file is located.
Then try python test.py
python test.py would try to execute the test.py from the current directory.
else try giving the complete path of the test.py
like "python /usr/local/bin/test.py"