This is a continuation from the last post on How to build and install the latest version of Python on Ubuntu. If you are simply looking to install Python packages, such as numpy, scipy, and matplotlib, on the default system Python (which is 2.7.6 for Ubuntu 14.04 LTS), the answer is quite simple:
$ sudo apt-get install python-numpy python-scipy python-matplotlib -y
The command will install the packages in the /usr/lib/python2.7/dist-packages directory. With this method, however, you can import those packages from the system default Python (version 2.7.6) but not from newly installed Python (version 2.7.11). Thus, in this post we will go over the steps to build and install the Python packages for the newly installed version.
First, we need to install setuptools package. We will need to download the script and run it.
$ wget https://bootstrap.pypa.io/ez_setup.py && sudo python ez_setup.py
Next, we need to install pip package. We will download the archive, extract, and run the script
$ wget https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
$ tar -xf pip-8.0.2.tar.gz
$ cd pip-8.0.2
$ sudo python setup.py
$ cd ..
Finally, use pip to install the packages
$ sudo pip install numpy scipy matplotlib
It will take quite some time to build, so please be patient. The packages will be installed in /usr/local/lib/python2.7/site-packages directory.
The first paragraph worked for me like a charm. I installed it for python 3.4, all I did was change python-numpy and so on to python3-numpy and so on.
ReplyDeleteThanks