Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named numpy

Tags:

python

numpy

I'm trying to run a program that requires Numpy to be installed. I thought it was, because if I try sudo apt-get install python-numpy it tells me that

sudo apt-get install python-numpy

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-numpy is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

But then when I go to install the program I'm trying to (within that programs directory, where setup.py is located) I get:

python setup.py install
Traceback (most recent call last):
   File "setup.py", line 20, in <module>
    from weblogolib import __version__
  File "/home/chris/Documents/IS/Bioinformatics-Software/weblogo-3.3/weblogolib/__init__.py", line 108, in <module>
     from numpy import array, asarray, float64, ones, zeros, int32,all,any, shape
ImportError: No module named numpy

When I look in the Python-2.7.3/Lib/site-packages directory the only thing that's in there is a README file. Shouldn't there be stuff from Numpy in there (and other install Python modules)?

I am running Ubuntu 12.04 with Python 2.7

Using dpkg -l python-numpy I get:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  python-numpy   1:1.6.1-6ubunt Numerical Python adds a fast array facility
like image 918
user1784467 Avatar asked Mar 14 '13 04:03

user1784467


People also ask

How do I fix No module named numpy?

The Python "ModuleNotFoundError: No module named 'numpy'" occurs when we forget to install the numpy module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install numpy command.

Is numpy installed but module not found?

Python numpy not found or no module named 'numpy' error appears when the module is not installed in the current working environment. Install the module using pip or conda to fix this issue. but make sure that you have installed it in current working environment.

How do I import numpy into Thonny?

Thonny uses its own virtual environment by default. Open "Tools => Manage packages" or "Tools => Open system shell" in order to install into this environment. For completeness I will add that once you are in the Thonny System Shell you can run either "pip" or "pip3" to install the module you need.


1 Answers

You do not mention where you are running the commands. For the commands, I guess you are using Ubuntu 12.10.

In Ubuntu 12.10 the default is Python3 (check it with python --version). So that, when you ran python setup ..., you are running it with the default python available. For what it is worth, weblog 3.3 requires Python 2.5, 2.6 or 2.7.

Also, you can check where python-numpy was installed (check it with dpkg -L python-numpy).

My shot out of the blue would be:

$ python2.7 setup.py install

If you do not have installed python2.7, you should install it (likely, the shell is going to suggest it).

like image 121
gpoo Avatar answered Oct 10 '22 16:10

gpoo