'How do I reset PYTHONPATH to "default" value in virtualenv?
I was struggling with installing dependencies for an external library (the requirements were already fulfilled) when I read that I should check if the install path is in my PYTHONPATH. It wasn't, so I looked up how to add it.
I came across this answer, and typed the code straight into the Terminal (not ~/.bashrc) before I finished reading.
If you're using bash (on a Mac or GNU/Linux distro), add this to your ~/.bashrc
export PYTHONPATH="${PYTHONPATH}:/my/other/path"
The path was I entered was /usr/bin/python.
Surprisingly this fixed all of my dependency problems.
However, since my Django project is dependent on a virtualenv, this ruined everything. I can no longer find how or where to restore my PYTHONPATH to.
I tried export PYTHONPATH="/home/[username]/.virtualenvs/[env]/bin/python" and also deleting the virtualenv with rmvirtualenv.
My next plan is to delete the project and pull again.
Solution 1:[1]
At the top of your Django settings module, you could include:
import sys
sys.path.append('/your/dependency/path')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Def_Os |
