4

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.

Community
  • 1
  • 1
Arvin
  • 71
  • 1
  • 6
  • You misunderstood. It was supposed to be a question as I haven't solved it. I edited the title for clarity. – Arvin Feb 10 '16 at 01:03
  • You pretty much break the idea of the virtual environment when using the system python library path. It would be much better to solve the dependency proplem instead of using a dirty workaround. So, what is the actual installation problem? – Klaus D. Feb 10 '16 at 02:38

1 Answers1

0

At the top of your Django settings module, you could include:

import sys
sys.path.append('/your/dependency/path')
Def_Os
  • 5,301
  • 5
  • 34
  • 63
  • Added this to the top of my settings.py, no change. `sys.path.append('/home/[username]/.virtualenvs/[env]/bin/python')` – Arvin Feb 10 '16 at 01:10
  • As you're working inside a virtualenv, that path was already included in the `PYTHONPATH`. I assumed you were going to add `/usr/bin/python`, or any other directory with your dependecy there. – Def_Os Feb 10 '16 at 04:26