0

On my system there is an installation of the same package in two locations. One is from super-user and another from local user, but the package installed from super-user is of old version. There are some missing functions, but when I run a script, it always looks in the default location, it does not find the module, and fails to run further. How would I specify that when I run a script, it looks into the local installation location. I edited .bashrc to set the PYTHONPATH for local installation location. It still does not work.

Super-user installation:

/usr/lib/python2.7/dist-packages/google/__init__.pyc

Local installation:

$HOME/.local/lib/python2.7/site-packages/google/__init__.pyc

.bashrc edit:

 export PYTHONPATH=$HOME/.local/lib/python2.7/site-packages:$PYTHONPATH
Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
thetna
  • 6,903
  • 26
  • 79
  • 113
  • See http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path for a workaround. Python basically follows a cascading process to load modules, where it first searches its modules cache to see if the module was loaded before and from which path, then it looks up locations from `find_module()` before finally hitting `sys.path` You might be better off using the workaround for simplicity. – Munir Nov 27 '15 at 14:39
  • 1
    Also, consider investigating and using [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) or [venv](https://docs.python.org/3/library/venv.html) for python3. This will let you create virtual environments for your python scripts, and the dependencies for each will be contained within each individual virtual environment. In this case your script will look for the dependency inside its virtual environment instead of the system installed libs – nstehr Nov 27 '15 at 15:28

0 Answers0