Reputation: 33
On my windows machine I created a virtual environement in conda where I run python 3.6. I want to permanently add a folder to the virtual python path environment. If I append something to sys.path
it is lost on exiting python.
Outside of my virtual enviroment I can just add to user variables by going to advanced system settings. I have no idea how to do this within my virtual enviroment.
Any help is much appreciated.
Upvotes: 3
Views: 9209
Reputation: 354
If you are on Windows 10+, this should work: 1) Click on the Windows button on the screen or on the keyboard, both in the bottom left section.
2) Type "Environment Variables" (without the quotation marks, of course).
3) Click on the option that says something like "Edit the System Environment Variables"
4) Click on the "Advanced Tab," and then click "Environment Variables" (Near the bottom)
5) Click "Path" in the top box - it should be the 3rd option - and then click "Edit" (the top one)
6) Click "New" at the top, and then add the path to the folder you want to create.
7) Click "Ok" at the bottom of all the pages that were opened as a result of the above-described actions to save.
That should work, please let me know in the comments if it doesn't.
Upvotes: -2
Reputation: 40683
"I can just add to user variables" just means adding an environment variable to the command shell. Virtualenv shouldn't (by default at least) clear environment variables. So it should just work if you already have PYTHONPATH
set.
If you only want the path available to the virtualenv then modify the file called Scripts/activate.bat
in the virtualenv folder and add the line:
set PYTHONPATH=path/to/dir
Upvotes: 7