现在,在Python 2.7中安装NumPy + SciPy会失败,并显示"RuntimeError:Python版本> = 3.5必需". [英] Installing NumPy + SciPy in Python 2.7 now fails with "RuntimeError: Python version >= 3.5 required"
问题描述
从这样的源代码安装numpy和scipy(例如,在新的Python 2.7 pyenv virtualenv
中):
Installing numpy and scipy from source like this (say, in a fresh Python 2.7 pyenv virtualenv
):
pip install numpy==1.14.6 scipy==1.0.1 --no-binary numpy,scipy
让他们的安装程序使用指向我的openblas安装的~/.numpy-site.cfg
文件.
gets their installers to use a ~/.numpy-site.cfg
file that points to my openblas installation.
这曾经起作用.现在,它会生成一个长堆栈跟踪,结尾为:
This used to work. Now it produces a long stack trace ending with:
File "/usr/local/var/pyenv/versions/2.7.16/envs/issue/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/var/folders/_b/q30qg_l50b5gvqd8y4_wb9h00000gn/T/easy_install-o9MJ5E/numpy-1.17.1/setup.py", line 31, in <module>
if sys.version_info[0] < 3:
RuntimeError: Python version >= 3.5 required.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
问发生了什么变化?
问:为什么在python 2.7安装中会显示Python version >= 3.5 required.
?
问:如何解决?
Q. What changed?
Q. Why does it say Python version >= 3.5 required.
in a Python 2.7 installation?
Q. How to fix it?
推荐答案
scipy 1.0.1
安装程序需要numpy
作为先决条件,但是多个安装程序一起工作最终得到了最新版本的numpy
,除非已经存在numpy
.
The scipy 1.0.1
installer requires numpy
as a prerequisite, but the multiple installers working together end up getting the latest version of numpy
unless numpy
is already present.
发生了什么变化:最新版本的numpy
需要Python 3.5+,因此会出现错误消息.
What changed: The latest version of numpy
requires Python 3.5+, hence the error message.
因此,即使pip
命令明确要求install numpy==1.14.6 scipy==1.0.1
,它也会触发更新的numpy
安装程序,该安装程序在Python 2上失败.(堆栈跟踪中的最后一项显示numpy-1.17.1
需要Python 3.)
So even though the pip
command explicitly asked to install numpy==1.14.6 scipy==1.0.1
, it triggers a newer numpy
installer that fails on Python 2. (The last entry in the stack trace shows numpy-1.17.1
requiring Python 3.)
问题出现在pip,scipy和numpy安装程序以及easy_install之间的交互中. pip问题#6945 中的详细信息.
The problem arises in the interaction between pip, the scipy and numpy installers, and easy_install. Details in pip issue #6945.
解决方法::首先安装numpy
.然后安装scipy
.另外,如果您不需要--no-binary
选项,则可以单行安装.
Workaround: Install numpy
first. Then install scipy
. Alternatively, the one-line install might work if you don't need the --no-binary
option.
这篇关于现在,在Python 2.7中安装NumPy + SciPy会失败,并显示"RuntimeError:Python版本> = 3.5必需".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!