Python Windows: the right virtual paths

I am new to virtualenv and don't know how to configure the paths. My paths were set like this:

PYTHONPATH=C:\Python27\ PYTHONSTARTUP=C:\Python27\Scripts\startup.py PATH=%PYTHONPATH%;...;%PYTHONPATH%\Scripts 

Should I remove these paths for virtualenv to activate the script to work correctly? If I can save my paths, then how can I call scripts for env when it was activated? Am I invoking scripts by explicitly launching them with python.exe instead of just entering the script name?

 python myscript.py 

Not sure how to handle the paths, and I would appreciate a little guidance.

+4
source share
2 answers

First, you have the wrong paths. PYTHONPATH tells Python which folders to look for Python modules in, and usually you don’t put the Python installation folder in it. To save the Python installation folder, there is another environment variable called PYTHONHOME . So instead of PYTHONPATH=C:\Python27\ you should have PYTHONHOME=C:\Python27\ . You must modify the PATH variable to use PYTHONHOME accordingly.

How to set environment variables when working with virtualenv; you don’t have to do anything because virtualenv retains its original values ​​when activated, changes the environment variables that need to be changed, and then restores the original values ​​when it is deactivated.

You can take a look at Using Python on Windows

+3
source

Think you're fine, just continue with virtual env (follow the docs), but remember you should use the cmd shell (NO POINT AND CLICKING !!). They took me a little before I realized that ...

Once you have activated and installed what you want in virtual env, you call scripts under the name "python scriptname"

-3
source

All Articles