ImportError: No module named scipy

2019-03-09 14:51发布

I am using Python 2.7 and trying to get PyBrain to work.

But I get this error even though scipy is installed -

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-
py2.7.egg/pybrain/__init__.py", line 1, in <module>
    from pybrain.structure.__init__ import *
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/__init__.py", line 1, in <module>
    from pybrain.structure.connections.__init__ import *
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/connections/__init__.py", line 1, in <module>
    from pybrain.structure.connections.full import FullConnection
  File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/connections/full.py", line 3, in <module>
    from scipy import reshape, dot, outer
ImportError: No module named scipy

I have installed scipy using this command -

sudo apt-get install python-scipy

I get -

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

What should I do?

12条回答
放荡不羁爱自由
2楼-- · 2019-03-09 15:17

Try to install it as a python package using pip. You said you already tried:

sudo apt-get install python-scipy

Now run:

pip install scipy

I ran both and it worked on my Debian-based box.

查看更多
贼婆χ
3楼-- · 2019-03-09 15:19

To ensure easy and correct installation for python use pip from the get go

To install pip:

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python2 get-pip.py   # for python 2.7
$ sudo python3 get-pip.py   # for python 3.x

To install scipy using pip:

$ pip2 install scipy    # for python 2.7
$ pip3 install scipy    # for python 3.x
查看更多
甜甜的少女心
4楼-- · 2019-03-09 15:19

Try to install it as a python package using pip as follows

$ sudo apt-get install python-scipy

If you want to run a python 3.x script, install scipy by:

$ pip3 install scipy
Otherwise install it by:
$ pip install scipy
查看更多
唯我独甜
5楼-- · 2019-03-09 15:22

if you are using pycharm go to settings and in project interpreter sub-tab click on "+" sign next to list and in the search bar in there search name "scipy" and install the package.

scipy

查看更多
Root(大扎)
6楼-- · 2019-03-09 15:24

This may be too basic (and perhaps assumable), but -

Fedora users can use:

sudo dnf install python-scipy

and then (For python3.x):

pip3 install scipy

or (For python2.7):

pip2 install scipy

查看更多
爷、活的狠高调
7楼-- · 2019-03-09 15:27

I recommend you to remove scipy via

apt-get purge scipy

and then to install it by

pip install scipy

If you do both then you might confuse you deb package manager due to possibly differing versions.

查看更多
登录 后发表回答