Python 导入错误:没有名为 scipy 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24808043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named scipy
提问by ihmpall
I am using Python 2.7 and trying to get PyBrain to work.
我正在使用 Python 2.7 并试图让 PyBrain 工作。
But I get this error even though scipy is installed -
但是即使安装了 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
I have installed scipy using this command -
我已经使用这个命令安装了 scipy -
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?
我该怎么办?
采纳答案by BostonGeorge
Try to install it as a python package using pip. You said you already tried:
尝试使用 pip 将其安装为 python 包。你说你已经试过了:
sudo apt-get install python-scipy
Now run:
现在运行:
pip install scipy
I ran both and it worked on my Debian-based box.
我运行了两者,它在我的基于 Debian 的机器上运行。
回答by RealityPC
Your python don't know where you installed scipy. add the scipy path to PYTHONPATH
and I hope it will solve your problem.
你的 python 不知道你在哪里安装了 scipy。将 scipy 路径添加到PYTHONPATH
,我希望它能解决您的问题。
回答by thomas.mc.work
I recommend you to remove scipy via
我建议您通过以下方式删除 scipy
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.
如果两者都做,那么由于版本可能不同,您可能会混淆 deb 包管理器。
回答by thomas.mc.work
To ensure easy and correct installation for python use pip from the get go
为确保 Python 的简单和正确安装,请从一开始就使用 pip
To install pip:
要安装 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:
使用 pip 安装 scipy:
$ pip2 install scipy # for python 2.7
$ pip3 install scipy # for python 3.x
回答by Ogglas
If you need to get scipy
in your Pyhton environment on Windows you can get the *.whl files here:
如果您需要进入scipy
Windows 上的 Pyhton 环境,您可以在此处获取 *.whl 文件:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
Remember that you need to install numpy+mkl
before you can install scipy
.
请记住,您需要先安装,numpy+mkl
然后才能安装scipy
。
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
When you have downloaded the correct *.whl files just open a cmd prompt in the download directory and run pip install *.whl
.
下载正确的 *.whl 文件后,只需在下载目录中打开 cmd 提示符并运行pip install *.whl
.
回答by Beyhan Gül
For windows users:
对于 Windows 用户:
I found this solution after days. Firstly which python version you want to install?
几天后我找到了这个解决方案。首先你想安装哪个python版本?
If you want for Python 2.7 version:
如果你想要 Python 2.7 版本:
STEP 1:
第1步:
scipy?0.19.0?cp27?cp27m?win32.whl
scipy?0.19.0?cp27?cp27m?win_amd64.whl
numpy?1.11.3+mkl?cp27?cp27m?win32.whl
numpy?1.11.3+mkl?cp27?cp27m?win_amd64.whl
scipy?0.19.0?cp27?cp27m?win32.whl
scipy?0.19.0?cp27?cp27m?win_amd64.whl
numpy?1.11.3+mkl?cp27?cp27m?win32.whl
numpy?1.11.3+mkl?cp27?cp27m?win_amd64.whl
If you want for Python 3.4 version:
如果你想要 Python 3.4 版本:
scipy?0.19.0?cp34?cp34m?win32.whl
scipy?0.19.0?cp34?cp34m?win_amd64.whl
numpy?1.11.3+mkl?cp34?cp34m?win32.whl
numpy?1.11.3+mkl?cp34?cp34m?win_amd64.whl
scipy?0.19.0?cp34?cp34m?win32.whl
scipy?0.19.0?cp34?cp34m?win_amd64.whl
numpy?1.11.3+mkl?cp34?cp34m?win32.whl
numpy?1.11.3+mkl?cp34?cp34m?win_amd64.whl
If you want for Python 3.5 version:
如果你想要 Python 3.5 版本:
scipy?0.19.0?cp35?cp35m?win32.whl
scipy?0.19.0?cp35?cp35m?win_amd64.whl
numpy?1.11.3+mkl?cp35?cp35m?win32.whl
numpy?1.11.3+mkl?cp35?cp35m?win_amd64.whl
scipy?0.19.0?cp35?cp35m?win32.whl
scipy?0.19.0?cp35?cp35m?win_amd64.whl
numpy?1.11.3+mkl?cp35?cp35m?win32.whl
numpy?1.11.3+mkl?cp35?cp35m?win_amd64.whl
If you want for Python 3.6 version:
如果你想要 Python 3.6 版本:
scipy?0.19.0?cp36?cp36m?win32.whl
scipy?0.19.0?cp36?cp36m?win_amd64.whl
numpy?1.11.3+mkl?cp36?cp36m?win32.whl
numpy?1.11.3+mkl?cp36?cp36m?win_amd64.whl
scipy?0.19.0?cp36?cp36m?win32.whl
scipy?0.19.0?cp36?cp36m?win_amd64.whl
numpy?1.11.3+mkl?cp36?cp36m?win32.whl
numpy?1.11.3+mkl?cp36?cp36m?win_amd64.whl
Link: [click[1]
链接:[点击[1]
Once finish installation, go to your directory.
安装完成后,转到您的目录。
For example my directory:
例如我的目录:
cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip install [where/is/your/downloaded/scipy_whl.]
STEP 2:
第2步:
Numpy+MKL
麻木+MKL
From same web site based on python version again:
再次来自基于 python 版本的同一网站:
After that use same thing again in Script folder
之后在 Script 文件夹中再次使用相同的东西
cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip3 install [where/is/your/downloaded/numpy_whl.]
And test it in python folder.
并在 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
回答by yahani manawadu
Try to install it as a python package using pip as follows
尝试使用 pip 将其安装为 python 包,如下所示
$ sudo apt-get install python-scipy
If you want to run a python 3.x script, install scipy by:
如果要运行 python 3.x 脚本,请通过以下方式安装 scipy:
$ pip3 install scipy
Otherwise install it by:
$ pip install scipy
回答by Akash Agarwal
My problem was that I spelt one of the libraries wrongly when installing with pip3, which ended up all the other downloaded libaries in the same command not being installed. Just run pip3 install on them again and they should be installed from their cache.
我的问题是,在使用 pip3 安装时,我拼错了其中一个库,最终导致未安装同一命令中的所有其他下载的库。只需再次对它们运行 pip3 install ,它们就应该从它们的缓存中安装。
回答by Shrinath Joshi
For Windows User : pip install -U scipy
对于 Windows 用户:pip install -U scipy
回答by Karim Pazoki
I had a same problem because I installed both of python2.7 and python3. when I run program with python3 I received same error. I install scipy with this command and problem has been solved:
我有同样的问题,因为我安装了 python2.7 和 python3。当我用 python3 运行程序时,我收到了同样的错误。我用这个命令安装了 scipy,问题已经解决:
sudo apt-get install python3-scipy