Snerd
Snerd

Reputation: 1553

Change Python environment variable PYTHONUSERBASE

How do I change the environment variable PYTHONUSERBASE.

For example in Windows I want it to be:

c:\mysite

I tried this:

set PYTHONUSERBASE=c:\mysite

When I run python setup.py install --user

it still installs to the default location.

I am using Windows 7 with PowerShell.

More info here about how to use PYTHONUSERBASE. http://www.python.org/dev/peps/pep-0370/

I noticed most people prefer virtualenv but Python 2.6 introduced this new method.

Upvotes: 1

Views: 6619

Answers (2)

Pavman
Pavman

Reputation: 124

Here's the proper way to add/update user env vars via powershell if someone happens upon this thread:

$myDir = "C:\mysite"
[System.Environment]::SetEnvironmentVariable("PYTHONUSERBASE", $myDir, "USER")

Upvotes: 0

Maciej Gol
Maciej Gol

Reputation: 15854

Start -> Computer -> (Right Click) Properties -> Advanced System Settings -> Environment Variables

You might need to restart your active PowerShell session for the new environment variables to kick in.

To change it from within PowerShell try:

$env:PYTHONUSERBASE = "c:\mysite"

Upvotes: 4

Related Questions