繁体   English   中英

如何在Windows上为PyPy安装numpy?

[英]How to install numpy for PyPy on Windows?

我刚刚在Windows上安装了PyPy ,并且在我运行的一些模拟代码中看到了大约10倍的速度提升。 我也希望看到使用numpy的代码类似。 我不是一个经验丰富的Python程序员,但我发现很难遵循这些说明 有没有人知道如果在Windows上为PyPy安装numpy是可能的,如果是这样,最简单的方法是什么?

说明提供了两个选项。

选项1

如果你有pip(命令行假定它找到属于PyPy的pip,而不是CPython中的pip):

pip install git+https://bitbucket.org/pypy/numpy.git

这似乎是一个很好的选择,但我找不到我解压缩到的目录结构中的pip

选项2

或者,直接的方式:

git clone https://bitbucket.org/pypy/numpy.git
cd numpy
pypy setup.py install

我在Windows上没有git ,但我也怀疑这个选项可能涉及从https://bitbucket.org/pypy/numpy.git编译源代码,甚至可能不可能(或者需要大量的黑客攻击) )在Windows上。

编辑

通过安装PIP https://sites.google.com/site/pydatalog/python/pip-for-windows按照下面的答案 ,或在说明这个答案的问题, 我如何在Windows上安装PIP? ConnectionError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /packages/py2.py3/p/pip/pip-1.5.4-py2.py3-none-any.whl (Caused by <class 'httplib.BadStatusLine'>: '')失败ConnectionError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /packages/py2.py3/p/pip/pip-1.5.4-py2.py3-none-any.whl (Caused by <class 'httplib.BadStatusLine'>: '') 例如,参见此错误报告 但是能够通过微软的Visual Studio安装PIP PTVS通过右键单击在Solution Explorer中的Python环境PyPy 2.7,选择安装Python包。 这无法安装numpy(另一个连接错误),但确实安装了pip。

现在我有了pip,我尝试使用pip install git+https://bitbucket.org/pypy/numpy.git在命令行上安装numpy。 首先我需要安装git才能做到这一点......没问题。 但随后它失败了以下

building library "npymath" sources
No module named numpy.distutils.msvccompiler in numpy.distutils; trying from distutils
error: Unable to find vcvarsall.bat

我不熟悉Python软件包的安装,我不确定这意味着什么。 我安装了C ++编译器的Visual Studio 2012,但另一方面,Python 3.3的这个线程 (我现在使用2.7)似乎暗示不应该需要C ++编译器。

编辑

这似乎与pip安装无关。 选项2

git clone https://bitbucket.org/pypy/numpy.git
cd numpy
pypy setup.py install

我仍然Unable to find vcvarsall.bat 但是,从这个答案中提示,如果将环境变量VS90COMNTOOLS设置为适当的目录, vcvarsall.bat可以找到VS90COMNTOOLS 在我的情况下,我有VS2012,所以适当的行是

set VS90COMNTOOLS=%VS110COMNTOOLS%

现在可以找到编译器,但是存在编译错误

_configtest.c
_configtest.c(4) : error C2061: syntax error : identifier 'npy_check_sizeof_type'
_configtest.c(4) : error C2059: syntax error : ';'
_configtest.c(7) : error C2065: 'npy_check_sizeof_type' : undeclared identifier error:

看起来这是在编译过程中生成的文件,甚至可能根本不需要构建。 不过我觉得我现在可能真的被卡住了......

对于第一个选项,您应该从中下载点子

https://sites.google.com/site/pydatalog/python/pip-for-windows

之后你应该在环境变量PATH中加入pip的路径。
最后,您应该使用命令提示符并使用

pip install git + https://bitbucket.org/pypy/numpy.git

我认为numpy没有任何区别:Pypy旨在加速本机python代码,而numpy是用C语言编写的(以及python),并且可能已经编译以最大化速度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM