Reputation: 105
I am trying to create a batch file to automatically add my python folder to the Environment Path. Below is my environment variables before the file was run.
And this is the file I ran (Note the bat file is in the same directory as the python folder):
@echo OFF
setx path "%path%;%cd%\Python36"
This file added python to path (see the red underline) but also added a bunch of other folders to the path (blue circle). I am confused as to why this occurred. Any help would be greatly appreciated!
Upvotes: 3
Views: 20002
Reputation: 330
There is a couple different ways.
First - Search for python, then set the $PATH.
FOR /f %%p in ('where python') do SET PYTHONPATH=%%p
ECHO %PYTHONPATH%
Second - If you know where Python is installed, you can use setx
to permanently set PATH
or PYTHONPATH
.
setx path "%path%;C:\Users\Admin\AppData\Local\Programs\Python\PythonVersion;"
I found an extremely intensive PowerShell script for installing Python. Just needs the links updated.
Upvotes: 3