Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I'd like to see similar on code using numpy, too. I'm not an experienced Python programmer however and I'm finding the instructions hard to follow. Does anyone know if installing numpy for PyPy on Windows is possible and if so what's the easiest way to do it?

The instructions provide two options.

Option no 1

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

this seems like a great option but I can't find pip in the directory structure I unzipped into.

Option no 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.

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?, 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'>: ''). See, e.g., 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. This failed to install numpy (with another connection error) but did install 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. First of all I needed to install git to do this... no problem. 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. 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.

Edit

This seems to be nothing to do with pip installation. Following option 2

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

I still get 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. In my case I have VS2012, so the appropriate line is

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...

like image 493
TooTone Avatar asked Apr 02 '14 16:04

TooTone


2 Answers

For the first option you should download pip from

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

After that you should add in enviroment variable PATH the path of the pip.
Finally , you should use command prompt and use the

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

like image 175
Dimitris Dimitriadis Avatar answered Oct 16 '22 17:10

Dimitris Dimitriadis


I don't think there would be any difference for numpy: Pypy is designed to speed up native python code, whereas numpy is written in C (as well as python) and is likely already compiled to maximise speed.

like image 20
Lewis Fogden Avatar answered Oct 16 '22 16:10

Lewis Fogden