Can't see numpy etc after upgrading Python on Ubuntu
Hi all. I hope this is the right place. It seems more like a Python problem than an Ubuntu problem. I use Python on Ubuntu 12.04. Recently I upgraded Python from 2.7.3 to 2.7.12. I did the upgrade via the source, i.e. download (from https://www.python.org/downloads/release/python-2712/ ), tar, ./config, sudo make install. After the upgrade, python could no longer see the 3rd party modules I use (numpy, scipy, matplotlib, cython). I can point PYTHONPATH to the cython files, but I can't work out how to include numpy, scipy and matplotlib. It's no good asking Ubuntu to upgrade, because apt-get tells me that numpy, scipy and matplotlib are all up to date. So what do I do so I can see these packages again? p.s. results of a few commands: $ which python /usr/local/bin/python $ find /usr -name 'numpy*' /usr/share/pyshared/numpy-1.6.1.egg-info /usr/share/pyshared/scipy/weave/numpy_scalar_spec.py /usr/share/pyshared/numpy /usr/share/pyshared/numpy/core/include/numpy /usr/share/pyshared/numpy/core/include/numpy/numpyconfig.h /usr/share/pyshared/numpy/numarray/include/numpy /usr/share/pyshared/numpy/testing/numpytest.py /usr/share/pyshared/numpy/distutils/numpy_distribution.py /usr/share/numpy /usr/lib/python2.7/dist-packages/numpy-1.6.1.egg-info /usr/lib/python2.7/dist-packages/scipy/weave/numpy_scalar_spec.py /usr/lib/python2.7/dist-packages/scipy/weave/numpy_scalar_spec.pyc /usr/lib/python2.7/dist-packages/numpy /usr/lib/python2.7/dist-packages/numpy/core/include/numpy /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/numpyconfig.h /usr/lib/python2.7/dist-packages/numpy/numarray/include/numpy /usr/lib/python2.7/dist-packages/numpy/testing/numpytest.py /usr/lib/python2.7/dist-packages/numpy/testing/numpytest.pyc /usr/lib/python2.7/dist-packages/numpy/distutils/numpy_distribution.pyc /usr/lib/python2.7/dist-packages/numpy/distutils/numpy_distribution.py /usr/lib/pyshared/python2.7/numpy /usr/local/lib/python2.7/dist-packages/Cython/Includes/numpy /usr/include/python2.7/numpy /usr/include/python2.7_d/numpy /usr/include/numpy ... and fairly similar results for scipy and matplotlib. My bash PYTHONPATH is: PYTHONPATH=:/home/peter/dvd/software/python:/home/peter/Cython-0.25.2 My sys.path in python is: >>> sys.path ['', '/home/peter', '/home/peter/dvd/software/python', '/home/peter/Cython-0.25.2', '/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'] -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't see numpy etc after upgrading Python on Ubuntu
Thanks Chris for replying, but it didn't work. The upgrade happened, but still python can't see numpy! So it seems to be a path problem. The numpy (and scipy and matplotlib) files are there, so surely in principle it's a simple matter of pointing my python path at them? Any ideas how? (I should add, the reason I upgraded python from source in the first place is that "apt-get" claimed python was up to date). p.s. Here's an abridged log: peter@sirboris:~$ which python /usr/local/bin/python peter@sirboris:~$ pip The program 'pip' is currently not installed. You can install it by typing: sudo apt-get install python-pip peter@sirboris:~$ sudo apt-get install python-pip [lots of output, pip installed] peter@sirboris:~$ which pip /usr/bin/pip peter@sirboris:~$ sudo pip install numpy Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages Cleaning up... peter@sirboris:~$ sudo pip install numpy --upgrade [lots and lots of output, successful install] peter@sirboris:~$ python Python 2.7.12 (default, Dec 11 2016, 22:16:38) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy >>> import sys >>> sys.path ['', '/home/peter', '/home/peter/dvd/software/python', '/home/peter/Cython-0.25.2', '/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'] # [Then I thought, maybe "pip" and "python -m pip" are different, so...] peter@sirboris:~$ sudo python -m pip install numpy /usr/local/bin/python: No module named pip -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't see numpy etc after upgrading Python on Ubuntu
OK thanks both of you. I didn't realise there was a distinction between system python and other (user/personal) python. Yes, python2.7.3 is still there in /usr/bin/python . /usr/bin/python appears to be getting numpy and scipy from /usr/lib/python2.7/dist-packages . So I added that to PYTHONPATH and reran python (i.e. /usr/local/bin/python, which is 2.7.12). But now when I "import numpy" I get an error message which ends in: File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 5, in import multiarray ImportError: /usr/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString So for now I give up. But the good news is that I have learned that my "old" python (2.7.3) is still on my machine. So for now I am renaming /usr/local/bin/python to /usr/local/bin/python2.7.12 , and going back to using python 2.7.3. -- https://mail.python.org/mailman/listinfo/python-list