0

I upgraded my local and remote versions of python to 2.7.9 - somewhere along the way - all of my packages were removed? I cannot make use of Flask outside of a virtualenv? While I was installing remotely I downloaded a virtualenv and proceeded to install pip, flask, etc.

I am not certain that downloading Python 2.7.9 is to blame. Whenever I enter the python interpreter and import my previously installed packages, i.e. Flask, they are not available.. I then proceed to sudo install globally and still the packages are not available despite my terminal saying the installations were success - for some reason my packages will now only work inside of a virtualenv?

I have follow this post Import error in twilio and I have identified Python 2.7 directory and contents as follows

/usr/local/bin/python

> 2to3        ipcontroller   iptest    pydoc      python2.7-config idle
> ipcontroller2  iptest2   python     python2-config ipcluster  
> ipengine       ipython   python2    python-config ipcluster2 
> ipengine2      ipython2  python2.7  smtpd.py

/usr/bin/pip

only one pip installed

..again even when I install outside of a virtualenv, I receive a successful install message for i.e. Flask but it is not installed when I check in the python interpreter, how could I fix this? Is this unique to Python 2.7.9?

Community
  • 1
  • 1
phillipsK
  • 1,466
  • 5
  • 29
  • 43
  • probably because you were using `/usr/bin/python` before and you installed a second interpreter not upgraded the system python – Padraic Cunningham Dec 25 '14 at 01:27
  • I did upgrade python, I compared past interpreter instances with my current - at the beginning of an interpreter instance, the python version is displayed – phillipsK Dec 25 '14 at 02:16
  • regardless, how could I fix? – phillipsK Dec 25 '14 at 02:27
  • what does `which -a python` output – Padraic Cunningham Dec 25 '14 at 10:54
  • because you see a newer python version does not mean you updated the system python, the fact you have a `/usr/local/bin/python` assures me you did not – Padraic Cunningham Dec 25 '14 at 12:20
  • which -a python `/usr/local/bin/python /usr/bin/python` How could I fix this? – phillipsK Dec 28 '14 at 19:46
  • yes so you have two installs, try starting interpreters with `/usr/bin/python` and `/usr/local/bin/python` try importing in both. – Padraic Cunningham Dec 28 '14 at 19:48
  • Can not import in either directory path – phillipsK Dec 28 '14 at 19:49
  • what does import sys sys.path show? And when you install a package with pip where does in say it is installed? – Padraic Cunningham Dec 28 '14 at 19:51
  • `The program 'import' can be found in the following packages: * imagemagick * graphicsmagick-imagemagick-compat Try: sudo apt-get install ` – phillipsK Dec 28 '14 at 19:52
  • you have to run that from a python interpreter not bash, what did you see when you ran `/usr/bin/python`? – Padraic Cunningham Dec 28 '14 at 19:55
  • `/usr/bin$ python Python 2.7.9 (default, Dec 24 2014, 21:39:12) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys sys.path File "", line 1 import sys sys.path ^ SyntaxError: invalid syntax` – phillipsK Dec 28 '14 at 20:00
  • it should be on different lines, where is pip installing your packages? – Padraic Cunningham Dec 28 '14 at 20:02
  • `/usr/bin$ pip install Flask Requirement already satisfied (use --upgrade to upgrade): Flask in /usr/local/lib/python2.7/dist-packages` – phillipsK Dec 28 '14 at 20:09
  • ok so start an interpreter with `/usr/local/bin/python` on one line import sys then on another line sys.path and see if `/usr/local/lib/python2.7` is in there – Padraic Cunningham Dec 28 '14 at 20:15
  • `/usr/local/bin$ python Python 2.7.9 (default, Dec 24 2014, 21:39:12) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> import sys.path Traceback (most recent call last): File "", line 1, in ImportError: No module named path >>> ` Will not let me import `sys.path` – phillipsK Dec 28 '14 at 20:30
  • I did not have `import sys.path` in my comment, just `sys.path` after importing sys – Padraic Cunningham Dec 28 '14 at 20:31
  • `['', '/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', '/usr/local/lib/python2.7/site-packages']` – phillipsK Dec 28 '14 at 21:14
  • so it is there, so in that same interpreter `import flask` does not work? – Padraic Cunningham Dec 28 '14 at 21:14
  • `>>> import flask Traceback (most recent call last): File "", line 1, in ImportError: No module named flask >>> ` No – phillipsK Dec 28 '14 at 21:19
  • ok one last thing, do import sys, `sys.path.insert(1,"/usr/local/lib/python2.7/dist-packages")` then try to import again, on separate lines again – Padraic Cunningham Dec 28 '14 at 22:22
  • that works session only, for a global effect, I have tried utilizing https://help.ubuntu.com/community/EnvironmentVariables#File-location_related_variables but my `echo $PATH` displays `/usr/local/lib/python2.7/dist-packages` and still importing flask or any library does not seem to be reading my $PATH ? – phillipsK Dec 29 '14 at 03:23
  • if I were you I would remove the `/usr/local/bin/python` then reinstall pip using `sudo python get-pip.py` you can get that file here https://bootstrap.pypa.io/get-pip.py – Padraic Cunningham Dec 29 '14 at 11:03

0 Answers0