python - 如何在 Windows 上为 PyPy 安装 numpy?

标签 python windows numpy pypy

我刚刚安装了 PyPy在 Windows 上,我看到我正在运行的一些模拟代码的速度提高了大约 10 倍。我也希望看到类似的代码使用 numpy。然而,我不是经验丰富的 Python 程序员,我正在寻找 instructions很难理解。有谁知道是否可以在 Windows 上为 PyPy 安装 numpy,如果可以,最简单的方法是什么?

说明提供了两个选项。

选项一

If you have pip (the command-line assumes that it finds the pip belonging to PyPy, not the one from CPython):

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

这似乎是个不错的选择,但我找不到 pip在我解压缩到的目录结构中。

选项 2

Alternatively, the direct way:

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

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

编辑

通过 https://sites.google.com/site/pydatalog/python/pip-for-windows 安装 pip根据 the answer below ,或 this answer 中的说明问题How do I install pip on Windows? , 失败 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'>: '') .参见,例如 this bug report .但是我能够通过 Microsoft Visual Studio 安装 pip PTVS通过右键单击解决方案资源管理器中 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,但另一方面 this thread对于 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 .但是,从 this answer 得到提示, 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:

这似乎是一个在编译过程中生成的文件,可能甚至不需要构建。不过我想我现在可能真的卡住了......

最佳答案

对于第一个选项,您应该从

下载 pip

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

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

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

关于python - 如何在 Windows 上为 PyPy 安装 numpy?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22817415/

相关文章:

windows - 带有变量的目录中的 mysqldump 空间

.net - Windows 上是否有 Valgrind for .Net 的等价物?

c# - 如何使用 Project Oxford 的语音 API 将解决方案实现到 WPF 应用程序中?

python - 从 numpy 数组中获取第 n 个元素

python - django-auth-ldap - 查找用户是否属于 ldap 组

python - 反转字符串顺序

python - 存储和读取大量 3d 数据集的节省空间的方法?

python - 我怎样才能有效地进行这个 numpy 数组操作?

python - 如何从文件中提取特定的行和列并将其保存在另一个文件中

python - 反转 numpy 数组或 pandas DataFrame 中的偶数行