I’ve come across this problem before, but today I was trying to install some Python packages after downloading the newest version of STSCI_PYTHON. Using easy_install requires root access to write the install files, so one would have to use, for example:
sudo easy_install pip
I got an error like
ImportError: No module named pkg_resources, which resulted from the fact that the “sudo” account wasn’t using the PYTHONPATH that was setup in the
~/.bashrc file. You could see this by running:
sudo python >>> import os >>> os.getenv('PYTHONPATH') ()
I found a fix for this here:
/etc/sudoers (with sudo) to add the following line:
Defaults env_keep += "PYTHONPATH"
Now the PYTHONPATH variable should be preserved when you invoke sudo and
sudo easy_install ... should work.