Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Windows: correct virtualenv paths

I'm new to virtualenv and not sure how to set up paths. My paths have been set to something like this:

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

Should I remove those paths for virtualenv's activate script to work correctly? If I can keep my paths then how do I call scripts for an env when it has been activated? Do I call scripts by explicitly running them with python.exe instead of simply typing the script name alone?

python myscript.py

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

like image 551
Jeff LaFay Avatar asked Nov 25 '22 14:11

Jeff LaFay


1 Answers

First, you have your paths wrong. PYTHONPATH tells Python in what folders to look for Python modules and normally you don't put Python's installation folder in it. For keeping installation folder of Python there's different environment variable called PYTHONHOME. So instead of PYTHONPATH=C:\Python27\ you should have PYTHONHOME=C:\Python27\. You should change PATH variable to use PYTHONHOME accordingly.

As to how to set environment variables when working with virtualenv; you don't need to do anything because virtualenv stores original values when it's activated, modifies environment variables it needs to modify and then restores original values when it's deactivated.

You can take a look at Using Python on Windows

like image 87
Piotr Dobrogost Avatar answered Dec 04 '22 06:12

Piotr Dobrogost