简体   繁体   English

如何在Windows上为PyPy安装numpy?

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

I've just installed PyPy on Windows and seen an approximately 10x speed improvement in some simulation code I'm running. 我刚刚在Windows上安装了PyPy ,并且在我运行的一些模拟代码中看到了大约10倍的速度提升。 I'd like to see similar on code using numpy, too. 我也希望看到使用numpy的代码类似。 I'm not an experienced Python programmer however and I'm finding the instructions hard to follow. 我不是一个经验丰富的Python程序员,但我发现很难遵循这些说明 Does anyone know if installing numpy for PyPy on Windows is possible and if so what's the easiest way to do it? 有没有人知道如果在Windows上为PyPy安装numpy是可能的,如果是这样,最简单的方法是什么?

The instructions provide two options. 说明提供了两个选项。

Option no 1 选项1

If you have pip (the command-line assumes that it finds the pip belonging to PyPy, not the one from CPython): 如果你有pip(命令行假定它找到属于PyPy的pip,而不是CPython中的pip):

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

this seems like a great option but I can't find pip in the directory structure I unzipped into. 这似乎是一个很好的选择,但我找不到我解压缩到的目录结构中的pip

Option no 2 选项2

Alternatively, the direct way: 或者,直接的方式:

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

I haven't got git on Windows, but also I'm suspicious this option might involve compiling source code from https://bitbucket.org/pypy/numpy.git , and might not even be possible (or require a lot of hacking) on Windows. 我在Windows上没有git ,但我也怀疑这个选项可能涉及从https://bitbucket.org/pypy/numpy.git编译源代码,甚至可能不可能(或者需要大量的黑客攻击) )在Windows上。

Edit 编辑

Installing pip via https://sites.google.com/site/pydatalog/python/pip-for-windows as per the answer below , or the instructions in this answer to the question How do I install pip on Windows? 通过安装PIP https://sites.google.com/site/pydatalog/python/pip-for-windows按照下面的答案 ,或在说明这个答案的问题, 我如何在Windows上安装PIP? , failed with 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'>: '')失败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'>: '') See, eg, this bug report . 例如,参见此错误报告 However I was able to install pip via Microsoft Visual Studio PTVS by right-clicking PyPy 2.7 under Python environments in Solution Explorer, selecting Install Python Package. 但是能够通过微软的Visual Studio安装PIP PTVS通过右键单击在Solution Explorer中的Python环境PyPy 2.7,选择安装Python包。 This failed to install numpy (with another connection error) but did install pip. 这无法安装numpy(另一个连接错误),但确实安装了pip。

Now that I have pip, I tried to install numpy on the command line using pip install git+https://bitbucket.org/pypy/numpy.git . 现在我有了pip,我尝试使用pip install git+https://bitbucket.org/pypy/numpy.git在命令行上安装numpy。 First of all I needed to install git to do this... no problem. 首先我需要安装git才能做到这一点......没问题。 But then it failed with the following 但随后它失败了以下

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

I'm unfamiliar with installation of Python packages and I'm not sure what this means. 我不熟悉Python软件包的安装,我不确定这意味着什么。 I do have Visual Studio 2012 with the C++ compiler installed, but on the other hand this thread for Python 3.3 (I'm using 2.7 at the moment) seems to imply that a C++ compiler shouldn't be needed. 我安装了C ++编译器的Visual Studio 2012,但另一方面,Python 3.3的这个线程 (我现在使用2.7)似乎暗示不应该需要C ++编译器。

Edit 编辑

This seems to be nothing to do with pip installation. 这似乎与pip安装无关。 Following option 2 选项2

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

I still get Unable to find vcvarsall.bat . 我仍然Unable to find vcvarsall.bat However, taking a hint from this answer , vcvarsall.bat can be found if you set the environment variable VS90COMNTOOLS to the appropriate directory. 但是,从这个答案中提示,如果将环境变量VS90COMNTOOLS设置为适当的目录, vcvarsall.bat可以找到VS90COMNTOOLS In my case I have VS2012, so the appropriate line is 在我的情况下,我有VS2012,所以适当的行是

set VS90COMNTOOLS=%VS110COMNTOOLS%

Now the compiler can be found but there is a compile error 现在可以找到编译器,但是存在编译错误

_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:

It seems like this is a file generated during the compile process that probably doesn't even need to be built. 看起来这是在编译过程中生成的文件,甚至可能根本不需要构建。 Nevertheless I think I might be really stuck now... 不过我觉得我现在可能真的被卡住了......

For the first option you should download pip from 对于第一个选项,您应该从中下载点子

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

After that you should add in enviroment variable PATH the path of the pip. 之后你应该在环境变量PATH中加入pip的路径。
Finally , you should use command prompt and use the 最后,您应该使用命令提示符并使用

pip install git+ https://bitbucket.org/pypy/numpy.git 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