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.
At the top of your Django settings
module, you could include:
import sys
sys.path.append('/your/dependency/path')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.