Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.4 and 2.7: Cannot install numpy package for python 3.4

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!

like image 447
SmCaterpillar Avatar asked Jul 22 '14 16:07

SmCaterpillar


People also ask

Why is my import NumPy not working?

Python import numpy is not working that means eithers the module is not installed or the module is corrupted. To fix the corrupted module, uninstall it first then reinstall it.

Is NumPy compatible with Python 2?

NumPy has been supporting both Python versions since 2010. This move doesn't come as a surprise with the Python core team itself dropping support for Python 2 in 2020.


1 Answers

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.

like image 64
Martijn Pieters Avatar answered Sep 19 '22 21:09

Martijn Pieters