Python 无法通过 pip 安装 Scipy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26575587/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:41:32  来源:igfitidea点击:

Can't install Scipy through pip

pythonscipy

提问by agconti

When installing scipy through pip with :

通过 pip 安装 scipy 时:

pip install scipy

Pip fails to build scipy and throws the following error:

Pip 无法构建 scipy 并抛出以下错误:

Cleaning up...
Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/Users/administrator/dev/KaggleAux/env/build/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/zl/7698ng4d4nxd49q1845jd9340000gn/T/pip-eO8gua-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/administrator/dev/KaggleAux/env/bin/../include/site/python2.7 failed with error code 1 in /Users/administrator/dev/KaggleAux/env/build/scipy
Storing debug log for failure in /Users/administrator/.pip/pip.log

How can I get scipy to build successfully? This may be a new issue with OSX Yosemite since I just upgraded and haven't had issues installing scipy before.

我怎样才能让 scipy 成功构建?这可能是 OSX Yosemite 的一个新问题,因为我刚刚升级并且之前没有遇到安装 scipy 的问题。



Debug log:

调试日志:

Cleaning up...
  Removing temporary dir /Users/administrator/dev/KaggleAux/env/build...
Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/Users/administrator/dev/KaggleAux/env/build/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/zl/7698ng4d4nxd49q1845jd9340000gn/T/pip-eO8gua-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/administrator/dev/KaggleAux/env/bin/../include/site/python2.7 failed with error code 1 in /Users/administrator/dev/KaggleAux/env/build/scipy
Exception information:
Traceback (most recent call last):
  File "/Users/administrator/dev/KaggleAux/env/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Users/administrator/dev/KaggleAux/env/lib/python2.7/site-packages/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Users/administrator/dev/KaggleAux/env/lib/python2.7/site-packages/pip/req.py", line 1435, in install
    requirement.install(install_options, global_options, *args, **kwargs)
  File "/Users/administrator/dev/KaggleAux/env/lib/python2.7/site-packages/pip/req.py", line 706, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/Users/administrator/dev/KaggleAux/env/lib/python2.7/site-packages/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command /Users/administrator/dev/KaggleAux/env/bin/python2.7 -c "import setuptools, tokenize;__file__='/Users/administrator/dev/KaggleAux/env/build/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/zl/7698ng4d4nxd49q1845jd9340000gn/T/pip-eO8gua-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/administrator/dev/KaggleAux/env/bin/../include/site/python2.7 failed with error code 1 in /Users/administrator/dev/KaggleAux/env/build/scipy

采纳答案by agconti

After opening up an issuewith the SciPy team, we found that you need to upgrade pip with:

在向 SciPy 团队提出问题后,我们发现您需要使用以下命令升级 pip:

pip install --upgrade pip

And in Python 3this works:

Python 3这部作品中:

python3 -m pip install --upgrade pip

for SciPy to install properly. Why? Because:

以便 SciPy 正确安装。为什么?因为:

Older versions of pip have to be told to use wheels, IIRC with --use-wheel. Or you can upgrade pip itself, then it should pick up the wheels.

必须告诉旧版本的 pip 使用轮子,IIRC 使用 --use-wheel。或者您可以升级 pip 本身,然后它应该会启动。

Upgrading pip solves the issue, but you might be able to just use the --use-wheelflag as well.

升级 pip 解决了这个问题,但您也可以只使用该--use-wheel标志。

回答by Liz Rice

After finding this answerfor some clues, I got this working by doing

在为一些线索找到这个答案后,我通过做

brew install gcc 
pip install scipy

(The first of these steps took 96 minutes on my 2011 Mac Book Air so I hope you're not in a hurry!)

(这些步骤中的第一步在我的 2011 Mac Book Air 上花费了 96 分钟,所以我希望你不要着急!)

回答by Chris Cheng

I face same problem when install Scipy under ubuntu.
I had to use command:

在 ubuntu 下安装 Scipy 时遇到同样的问题。
我不得不使用命令:

$ sudo apt-get install libatlas-base-dev gfortran
$ sudo pip3 install scipy

You can get more details here Installing SciPy with pip
Sorry don't know how to do it under OS X Yosemite.

您可以在此处获得更多详细信息使用 pip 安装 SciPy
抱歉不知道如何在 OS X Yosemite 下进行。

回答by Nazilla

If you are using CentOS you need to install lapack-devel like so:

如果你使用 CentOS,你需要像这样安装 lapack-devel:

 $ yum install lapack-devel

回答by ConorB

Microsoft Windows users of 64 bit Python installations will need to download the 64 bit .whlof Scipy from here, then simply cdinto the folder you've downloaded the .whlfile and run:

64 位 Python 安装的 Microsoft Windows 用户需要.whl这里下载 64 位Scipy ,然后只需cd进入您下载.whl文件的文件夹并运行:

pip install scipy-0.16.1-cp27-none-win_amd64.whl

回答by Box and Cox

  1. Download SciPy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
  2. Go into the directory the downloaded file is in and pip installthe file.
  3. Go to python shell, run import scipy; it worked for me with no errors.
  1. http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy下载 SciPy
  2. 进入下载文件所在的目录和pip install文件。
  3. 转到 python shell,运行import scipy;它对我有用,没有错误。

回答by Cyclotron3x3

In windows 10, most options will not work. Follow these steps:

在 Windows 10 中,大多数选项都不起作用。按着这些次序:

In Windows 10 with CMD, you cannot download scipydirectly using most of the well known commands like wget, cloning scipy github, pip install scipy, etc

To install, go to pythonlibs .whl files, and if you are using python 2.7 32 bitthen download numpy-1.11.2rc1+mkl-cp27-cp27m-win32.whl and scipy-0.18.1-cp27-cp27m-win32.whlor if python 2.7 62 bitthen download numpy-1.11.2rc1+mkl-cp27-cp27m-win_amd64.whl and scipy-0.18.1-cp27-cp27m-win_amd64.whl

After downloading,save the files under your python directory, in my case it was c:\>python27

Then run:

在Windows 10与CMD,你不能下载scipy直接使用最知名的命令喜欢的wgetcloning scipy githubpip install scipy,等

要安装,请转到pythonlibs .whl 文件,如果您正在使用python 2.7 32 bit然后下载numpy-1.11.2rc1+mkl-cp27-cp27m-win32.whl and scipy-0.18.1-cp27-cp27m-win32.whl或如果python 2.7 62 bit然后下载numpy-1.11.2rc1+mkl-cp27-cp27m-win_amd64.whl and scipy-0.18.1-cp27-cp27m-win_amd64.whl

下载后,将文件保存在您的python directory.c:\>python27

然后运行:

pip install C:\Python27\numpy-1.11.2rc1+mkl-cp27-cp27m-win32.whl 
pip install C:\Python27\scipy-0.18.1-cp27-cp27m-win32.whl

Note:

笔记:

  1. scipyneeds numpyas dependency, so that's why we are downloading numpybefore scipy.
  2. cp27in .whl files means that these files are meant for python 2.7and cp33stands for python 3.xspeciafically >=3.3
  1. scipy需要numpy作为依赖,所以这就是我们numpy之前下载scipy.
  2. cp27在 .whl 文件中意味着这些文件专门用于python 2.7cp33代表python 3.x>=3.3

回答by Arun Naudiyal

If you are totally new to python read step by step or go directly to last step. Follow the below method to install scipy 0.18.1 on Windows 64-bit , Python 64-bit . If below command is not working then proceed further

如果您完全不熟悉 Python,请逐步阅读或直接转到最后一步。按照以下方法在 Windows 64 位、Python 64 位上安装 scipy 0.18.1。如果以下命令不起作用,则继续进行

pip install scipy

Be careful with the versions of

小心这些版本

  1. Python

  2. Windows

  3. .whl version of numpy and scipy files

  4. First install numpy and scipy.

    pip install FileName.whl
    
  5. For Numpy:http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpyFor Scipy:http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

  1. Python

  2. 视窗

  3. .whl 版本的 numpy 和 scipy 文件

  4. 首先安装numpy和scipy。

    pip install FileName.whl
    
  5. 对于 Numpy:http: //www.lfd.uci.edu/~gohlke/pythonlibs/#numpy对于 Scipy:http: //www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

Be aware of the file name (check the version number).

注意文件名(检查版本号)。

Ex :scipy-0.18.1-cp35-cp35m-win_amd64.whl

例如:scipy-0.18.1-cp35-cp35m-win_amd64.whl

To check which version is supported by your pip, go to point No 2 below.

要检查您的 pip 支持哪个版本,请转到下面的第 2 点。

If you are using .whl file . Following errors are likely to occur .

如果您使用 .whl 文件。可能会出现以下错误。

  1. You are using pip version 7.1.0, however version 8.1.2 is available.
  1. 您使用的是 pip 版本 7.1.0,但版本 8.1.2 可用。

You should consider upgrading via the 'python -m pip install --upgrade pip' command

您应该考虑通过“python -m pip install --upgrade pip”命令进行升级

  1. scipy-0.15.1-cp33-none-win_amd64.whl.whl is not supported wheel on this platform
  1. scipy-0.15.1-cp33-none-win_amd64.whl.whl 在此平台上不受支持

For the above error: start Python and type :

对于上述错误:启动 Python 并键入:

import pip
print(pip.pep425tags.get_supported())

Output:

输出:

[('cp35', 'cp35m', 'win_amd64'), ('cp35', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp35', 'none', 'any'), ('cp3', 'none', 'any'), ('py35', 'none', 'any'), ('py3', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]

[('cp35', 'cp35m', 'win_amd64'), ('cp35', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp35', 'none ', 'any'), ('cp3', 'none', 'any'), ('py35', 'none', 'any'), ('py3', 'none', 'any'), ( 'py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]

In the output you will observe cp35 is there , so download cp35 for numpy as well as scipy.Further edits are most welcome.

在输出中,您将看到 cp35 存在,因此下载 numpy 和 scipy 的 cp35。欢迎进一步编辑。

回答by u_found_me

Try downloading the scipy file from the below link

尝试从以下链接下载 scipy 文件

https://sourceforge.net/projects/scipy/?source=typ_redirect

https://sourceforge.net/projects/scipy/?source=typ_redirect

It will be a .exe file and you just need to run it. But be sure to chose the scipy version corresponding to your python version.

它将是一个 .exe 文件,您只需要运行它。但是一定要选择与你的python版本对应的scipy版本。

When the scipy.exe file is run it will locate the python directory and will be installed .

当 scipy.exe 文件运行时,它将定位 python 目录并安装。

回答by Tharindu Kumara

This is an alternative to pip. I also had the same error when installing scipywith pip.

这是pip的替代品。使用 pip安装scipy时我也遇到了同样的错误。

Then I downloaded and installed MiniConda. And then I used the below command to install pytables.

然后我下载并安装了MiniConda。然后我使用下面的命令来安装 pytables。

conda install -c conda-forge scipy

Please refer the below screenshot.

请参考下面的截图。

enter image description here

在此处输入图片说明