0

I am unable to make the System Environment Variable Path work. I see no error/typo in the paths and they are exact matches, but the system is still unable to find the files I want to run. When I add a pause to my Batch file I am able to see the following error in the command prompt: "[Errno 2] No such file or directory".

I am trying to use a batch file (i.e. magic8ball.bat) to run a python script (i.e. magic8ball.py) by just typing in "magic8ball" in the Win + R prompt. I will include pictures of the file paths, the batch file contents, what I type into the run prompt, and the system environment variables.

The Path environment variable also doesn't work when I try to use Selenium's webdriver in another python script without manually specifying the exact path. You can see the exact webdriver path in the env variables, but doing "driver=webdriver.Chrome()" doesn't work. It only works if I manually declare the path with like "driver=webdriver.Chrome(executable_path=r'C:\webdriver\chrome\chromedriver.exe')".

Going back to the batch file, running it from the run prompt fails to find the batch file and clicking on the file manually fails to find the python file. Manually clicking on the batch file is what throws the error "[Errno 2] No such file or directory".

This works flawlessly on my old Windows 10 laptop that has the exact same paths and files, but I can't get it to work on my new Windows 11 laptop. I see no error/typo in the paths and have confirmed they are exact matches to where the files live. What am I missing or doing wrong?

System Environment Variables "Path"

Python Script File Path

Batch File Path

Batch File Contents

Run Prompt Contents

zleblond
  • 1
  • 2
  • 1
    Where are you specifying the path? In the batch file itself? – Gerhard Jun 02 '22 at 08:17
  • 2
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 02 '22 at 12:19
  • Please take a look on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) – Mofi Jun 02 '22 at 18:58
  • @Gerhard - The path to the files are being added to the System Environment Variables Path. The path to the batch files is there, the webdriver for selenium, and the python scripts I'm trying to run using the batch files. The batch file then starts python and runs the python script. The issue is the batch file is starting python but not finding the script to run. Same issue with the webdriver for Selenium. It works fine when I specify the path manually, but it doesn't work when I try to leverage the Environment Variables Path. I'm not sure why the env variable path values aren't working – zleblond Jun 03 '22 at 16:40

0 Answers0