2

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")
2

1 Answer 1

3

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?

Sign up to request clarification or add additional context in comments.

6 Comments

Thank 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?
In 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 ...
@Raffe81 : could you provide also an example of doing the same from within a Python script?
@Claudio pip is included in Python 2.7.9+ by default
import sys sys.path.append("C:\Python27") And then the same for your scripts path.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.