How to add Python and the Python Scripts directory to a PATH variable?
12,125
In windows command prompt:
set PATH=%PATH%;C:\Python27\;C:\Python27\Scripts\
Explanation:
set PATH=%PATH%; -- takes the current path and sets PATH to it.
C:\Python27\;C:\Python27\Scripts\ -- Adds your directories to the path
Is this what you were after?
Author by
stack
Updated on June 14, 2022Comments
-
stack almost 2 years
I'm trying to add Python and the Python scripts directory to the PATH variable. Here is the command I'm writing into CMD (I'm using Windows 8.1):
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User")
But CMD returns this:
The filename, directory name, or volume label syntax is incorrect.
Anyway, may please someone give me an example? How should I write command above into windows's CMD?
None of these work:
[Environment]::SetEnvironmentVariable("C:/", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User") [Environment]::SetEnvironmentVariable("Path", "C:/;C:\Python27\;C:\Python27\Scripts\", "User")
-
stack about 7 yearsThank you, upvote. I entered your command and I think it worked, because there wasn't any error. But you know, I'm trying to use implement this. Please scroll down to see "Installation On Windows" paragraph. Now when I write this command
pip install mitmproxy
, it says "'pip' is not recognized as an internal or external command, operable program or batch file.". Any idea? -
Claudio about 7 yearsIn order to use pip you have to install pip - and you can't use pip to install pip because pip is not installed :D ... So install pip first ...
-
Claudio about 7 years@Raffe81 : could you provide also an example of doing the same from within a Python script?
-
stack about 7 years@Claudio pip is included in Python 2.7.9+ by default
-
Raffe81 about 7 yearsimport sys sys.path.append("C:\Python27") And then the same for your scripts path.
-
Raffe81 about 7 yearsRegarding pip. If it is installed, what folder is it in? Is that folder in your PATH? Also if you just added the directories to your PATH I think you need to open a new command prompt for the changes to be affective.