ImportError:没有名为scipy的模块

问题描述 投票:73回答:12

我正在使用Python 2.7并尝试让PyBrain工作。

但即使安装了scipy,我也会收到此错误 -

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

我用这个命令安装了scipy -

sudo apt-get install python-scipy

我明白了 -

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.

我该怎么办?

python python-2.7 scipy pybrain
12个回答
122
投票

尝试使用pip将其安装为python包。你说你已经尝试过:

sudo apt-get install python-scipy

现在运行:

pip install scipy

我跑了两个,它在我的基于Debian的盒子上工作。


0
投票

你的python不知道你安装scipy的位置。添加scipy路径到scipy,我希望它能解决你的问题。


0
投票

我的问题是我在使用pip3进行安装时错误地拼写了其中一个库,这导致所有其他下载的库在未安装的同一命令中运行。只需再次在它们上运行pip3,就应该从它们的缓存中安装它们。


0
投票

这可能太基本了(也许可以假设),但是 -

Fedora用户可以使用:

PYTHONPATH

然后(对于python3.x):

sudo dnf install python-scipy

或(对于python2.7):

pip3 install scipy


16
投票

为了确保方便和正确的安装python使用点开始

要安装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

使用pip安装scipy:

$ pip2 install scipy    # for python 2.7
$ pip3 install scipy    # for python 3.x

6
投票

对于Windows用户:

几天后我找到了这个解决方案。首先要安装哪个python版本?

如果你想要Python 2.7版本:

步骤1:

SciPy的-0.19.0-cp27-cp27m-win32.whl

SciPy的-0.19.0-cp27-cp27m-win_amd64.whl

numpy的-1.11.3 + MRL-cp27-cp27m-win32.whl

numpy的-1.11.3 + MRL-cp27-cp27m-win_amd64.whl

如果你想要Python 3.4版本:

SciPy的-0.19.0-CP34-cp34m-win32.whl

SciPy的-0.19.0-CP34-cp34m-win_amd64.whl

numpy的-1.11.3 + MRL-CP34-cp34m-win32.whl

numpy的-1.11.3 + MRL-CP34-cp34m-win_amd64.whl

如果你想要Python 3.5版本:

SciPy的-0.19.0-CP35-cp35m-win32.whl

SciPy的-0.19.0-CP35-cp35m-win_amd64.whl

numpy的-1.11.3 + MRL-CP35-cp35m-win32.whl

numpy的-1.11.3 + MRL-CP35-cp35m-win_amd64.whl

如果你想要Python 3.6版本:

SciPy的-0.19.0-CP36-cp36m-win32.whl

SciPy的-0.19.0-CP36-cp36m-win_amd64.whl

numpy的-1.11.3 + MRL-CP36-cp36m-win32.whl

numpy的-1.11.3 + MRL-CP36-cp36m-win_amd64.whl

链接:[点击[1]

完成安装后,转到您的目录。

例如我的目录:

cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip install [where/is/your/downloaded/scipy_whl.]

第2步:

Numpy + MKL

从基于python版本的同一网站再次:

之后在Script文件夹中再次使用相同的东西

cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip3 install [where/is/your/downloaded/numpy_whl.]

并在python文件夹中测试它。

Python35>python 
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. 
>>>import scipy

3
投票

如果你需要在Windows上的Python环境中获得qazxsw poi,你可以在这里获得* .whl文件:

scipy

请记住,在安装http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy之前,您需要安装numpy+mkl

scipy

下载正确的* .whl文件后,只需在下载目录中打开cmd提示符并运行http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy


2
投票

我建议你删除scipy via

pip install *.whl

然后通过安装它

apt-get purge scipy

如果您同时执行这两项操作,那么由于版本可能不同,您可能会对deb软件包管理器感到困惑


2
投票

尝试使用pip将其安装为python包,如下所示

pip install scipy

如果要运行python 3.x脚本,请通过以下方式安装scipy:

$ sudo apt-get install python-scipy

2
投票

对于Windows用户:pip install -U scipy


2
投票

我遇到了同样的问题,因为我安装了python2.7和python3。当我用python3运行程序时,我收到了同样的错误。我使用此命令安装scipy并且问题已解决:

$ pip3 install scipy
Otherwise install it by:
$ pip install scipy

2
投票

如果您正在使用pycharm转到设置并在项目解释器子选项卡中单击列表旁边的“+”符号,并在搜索栏中搜索名称“scipy”并安装包。

sudo apt-get install python3-scipy

© www.soinside.com 2019 - 2024. All rights reserved.