1

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.

2 Answers 2

4

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"

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

4 Comments

I actually know that way. I want to change the PYTHONUSERBASE variable from WITHIN the command line specifically.
Try $env:PYTHONBASEUSER = "c:\mysite"
How should I check to see if it went into effect?
Get-ChildItem Env: to list all variables, $Env:PYTHONUSERBASE to print PYTHONUSERBASE variable. More about PowerShell environment variables can be found here technet.microsoft.com/en-us/library/ff730964.aspx
0

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

Comments

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.