0

I recently went to upgrade python on my ubuntu 14.04 from 2.7 to 2.7.11. Afterwards, I noticed that I kept getting errors on importing modules like Requests. I made sure to pip install requests and upgrade but to no avail. I went ahead and uninstalled python and reinstalled with a few other random things.

Later I found out that all my packages were in dist-packages and not in site-packages so I sought out to find a way to get python to call on that.

I ran this command found from this site:

export PYTHONPATH="/usr/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages"

When I run python -c "import sys; print sys.path"

['', '/usr/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload']

I run my python script and still get that error "ImportError: No module named requests" which can be found in the dist-packages folder.

How can I fix this without nuking my box?

All help is greatly appreciated!

kboparai1
  • 1
  • 2

1 Answers1

0

Ah I some how fixed it.

Pip Install not installing into correct directory?

Went there and tried running:

export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python:${PATH}

Nothing changed. Then I tried the following which broke things...

export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python:/usr/local/bin/python2.7

Then i found this on another website...which fixed what i did from the previous command.

export PATH=/bin:/usr/bin:/usr/local/bin:$PATH

After that i did which python and now it all seems to be working!

which python
/usr/bin/python

which pip
/usr/bin/pip
Community
  • 1
  • 1
kboparai1
  • 1
  • 2
  • Great to hear you fixed it @kboparai1! Be sure accept your own answer so others with a similar problem can find this post. And Welcome to StackOverflow! :) – davedwards Jun 15 '16 at 19:32
  • Thank you! I will mark it answered in a couple days! – kboparai1 Jun 15 '16 at 19:41
  • Hmm, after a while, this changes back to the normal path. I also tried out virtualenv but this won't work for long since I plan on running scripts via cron. – kboparai1 Jun 24 '16 at 20:12
  • Perhaps your `path` is changing back due to how windows handles environment variables, maybe [How to update PATH variable permanently from cmd? Windows](http://stackoverflow.com/questions/8358265/how-to-update-path-variable-permanently-from-cmd-windows) may help? – davedwards Jun 24 '16 at 20:19
  • hmm interesting. I'm on Ubuntu and will see what info i can find around this. – kboparai1 Jun 27 '16 at 20:48