'Unable to get a command executed in python
I am unable to run the following command C:\Users\deepa>python ..\scrape.py It gives me an error python: can't open file 'C:\Users\scrape.py': [Errno 2] No such file or directory
I have already set environment variables to get python executed from any directory.
Solution 1:[1]
If you have set your environment variables then you don't need to pass the path of the file (which you are passing is incorrect) while running the code. Just you can mention file name and it will get executed.
python scrape.py
Solution 2:[2]
For your command:
C:\Users\deepa>python ..\scrape.py
The problem is not related to the python path, it's about the ..\scrape.py, Please make sure this python script (scrape.py) is in the right place, I recommend you use absolute path instead of related path, for example:
C:\Users\deepa>python D:\test\test.py
D:\test\test.py is the absolute path of this python script (scrape.py), or you can drag this file into your terminal/cmd/PowerShell etc., you will see its absolute path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vaibhav Jadhav |
| Solution 2 | Vic Sun |
