Viewed   472 times

I am using Ubuntu 12.04 and want to use python 3.4 side by side with python 2.7.

The installation of python 3.4 worked properly. However, I cannot install the numpy package for python 3 (and as a consequence I can't install scipy, pandas etc.).

Using

 sudo pip3 install numpy

spits out the following error:

File "numpy/core/setup.py", line 289, in check_types

"Cannot compile 'Python.h'. Perhaps you need to "

SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

Btw, I already have python-dev installed.

Moreover, installing numpy via

 sudo apt-get install python-numpy

does not work either since I already installed numpy for python 2.7 and the installer responds that numpy is already up to date.

What can I do? Thanks!

 Answers

2

You have not installed the Python 3 development package. Install python3.4-dev:

apt-get install python3.4-dev

The main package never includes the development headers; Debian (and by extension Ubuntu) package policy is to put those into a separate -dev package. To install numpy however, you need these files to be able to compile the extension.

Wednesday, September 7, 2022
5

The easiest way I've found to install pip3 (for python3.x packages) on CentOS 7 is:

$ sudo yum install python34-setuptools
$ sudo easy_install-3.4 pip

You'll need to have the EPEL repository enabled before hand, of course.

You should now be able to run commands like the following to install packages for python3.x:

$ pip3 install foo
Thursday, October 27, 2022
 
5

If you do not have an entire Python distribution or you do not want to install one, you can download and install a compiled whl package from Christoph Gohlke's webpage. This whl contains numpy and is linked against mkl. When installing this package, you install both: numpy with the mkl dependencies.

All you have to do is:

  • download the correct whl file (Choose the right Python version and 32/64 file)
  • open a Windows cli with Windows+R and by running inside cmd
  • go to the directory where you have downloaded the whl file, with cd instructions
  • run pip install numpy?1.XX.Y+mkl?cp3X?cp3Xm?win_amd64.whl

For example, the command can be

pip install numpy?1.11.3+mkl?cp35?cp35m?win_amd64.whl

You can do it for any package with some code that has to be compiled

Wednesday, December 7, 2022
 
jasoni
 
4

Pillow is packaged as python3-pil in Ubuntu 14.04 (Trusty Tahr). You can install it system-wide with:

sudo apt-get install python3-pil

You seem to have already installed Pillow with pip earlier, but the default path it pip places it in is not read by the system Python. You can add it to the search path with:

export PYTHONPATH=/usr/local/lib/python3.4/dist-packages:/usr/local/lib/python3.4/site-packages

Generally you are better off using pip --user to avoid breaking the system installations or to stick with the packaged variants of base Python modules if possible.

Thursday, October 6, 2022
2

I would recommend EasyInstall, a package management application for Python.

Once you've installed EasyInstall, you should be able to go to a command window and type:

easy_install simplejson

This may require putting easy_install.exe on your PATH first, I don't remember if the EasyInstall setup does this for you (something like C:Python25Scripts).

Sunday, December 11, 2022
 
s16h
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :