Tony Babarino
Tony Babarino

Reputation: 3405

Installing numpy with pypy on mac osx

I'm unable to install numpy with pypy on mac. I have installed pypy using brew and when I try to execute:

    pip_pypy install numpy

I get this error:

   creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy/numpy
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy/numpy/_build_utils
creating build/temp.macosx-10.11-x86_64-2.7/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy/numpy/_build_utils/src
compile options: '-DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=3 -DHAVE_CBLAS -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Inumpy/core/include -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/local/Cellar/pypy/4.0.1/libexec/include -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -c'
extra options: '-msse3 -I/System/Library/Frameworks/vecLib.framework/Headers'
cc: numpy/core/src/multiarray/alloc.c
In file included from numpy/core/src/multiarray/alloc.c:8:
In file included from numpy/core/include/numpy/arrayobject.h:4:
In file included from numpy/core/include/numpy/ndarrayobject.h:27:
build/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy/__multiarray_api.h:28:12: error: visibility does not match previous declaration
    extern NPY_NO_EXPORT PyTypeObject PyArray_Type;
           ^
numpy/core/include/numpy/ndarraytypes.h:10:31: note: expanded from macro 'NPY_NO_EXPORT'
        #define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
                              ^
build/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy/_numpyconfig.h:25:46: note: expanded from macro 'NPY_VISIBILITY_HIDDEN'
#define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
                                             ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/pypy_decl.h:611:1: note: previous attribute is here
PyAPI_DATA(PyTypeObject) PyArray_Type;
^
/usr/local/Cellar/pypy/4.0.1/libexec/include/Python.h:15:35: note: expanded from macro 'PyAPI_DATA'
# define PyAPI_DATA(RTYPE) extern PyAPI_FUNC(RTYPE)
                                  ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/Python.h:14:43: note: expanded from macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) __attribute__((visibility("default"))) RTYPE
                                          ^
numpy/core/src/multiarray/alloc.c:109:30: error: use of undeclared identifier 'PyMem_MALLOC'
                            &PyArray_malloc);
                             ^
numpy/core/include/numpy/ndarraytypes.h:335:24: note: expanded from macro 'PyArray_malloc'
#define PyArray_malloc PyMem_Malloc
                       ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/pymem.h:8:22: note: expanded from macro 'PyMem_Malloc'
#define PyMem_Malloc PyMem_MALLOC
                     ^
2 errors generated.
In file included from numpy/core/src/multiarray/alloc.c:8:
In file included from numpy/core/include/numpy/arrayobject.h:4:
In file included from numpy/core/include/numpy/ndarrayobject.h:27:
build/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy/__multiarray_api.h:28:12: error: visibility does not match previous declaration
    extern NPY_NO_EXPORT PyTypeObject PyArray_Type;
           ^
numpy/core/include/numpy/ndarraytypes.h:10:31: note: expanded from macro 'NPY_NO_EXPORT'
        #define NPY_NO_EXPORT NPY_VISIBILITY_HIDDEN
                              ^
build/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy/_numpyconfig.h:25:46: note: expanded from macro 'NPY_VISIBILITY_HIDDEN'
#define NPY_VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
                                             ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/pypy_decl.h:611:1: note: previous attribute is here
PyAPI_DATA(PyTypeObject) PyArray_Type;
^
/usr/local/Cellar/pypy/4.0.1/libexec/include/Python.h:15:35: note: expanded from macro 'PyAPI_DATA'
# define PyAPI_DATA(RTYPE) extern PyAPI_FUNC(RTYPE)
                                  ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/Python.h:14:43: note: expanded from macro 'PyAPI_FUNC'
# define PyAPI_FUNC(RTYPE) __attribute__((visibility("default"))) RTYPE
                                          ^
numpy/core/src/multiarray/alloc.c:109:30: error: use of undeclared identifier 'PyMem_MALLOC'
                            &PyArray_malloc);
                             ^
numpy/core/include/numpy/ndarraytypes.h:335:24: note: expanded from macro 'PyArray_malloc'
#define PyArray_malloc PyMem_Malloc
                       ^
/usr/local/Cellar/pypy/4.0.1/libexec/include/pymem.h:8:22: note: expanded from macro 'PyMem_Malloc'
#define PyMem_Malloc PyMem_MALLOC
                     ^
2 errors generated.
error: Command "cc -arch x86_64 -O2 -fPIC -Wimplicit -O2 -fPIC -Wimplicit -O2 -fPIC -Wimplicit -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=3 -DHAVE_CBLAS -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Inumpy/core/include -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/local/Cellar/pypy/4.0.1/libexec/include -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -Ibuild/src.macosx-10.11-x86_64-2.7/numpy/core/src/private -c numpy/core/src/multiarray/alloc.c -o build/temp.macosx-10.11-x86_64-2.7/numpy/core/src/multiarray/alloc.o -msse3 -I/System/Library/Frameworks/vecLib.framework/Headers" failed with exit status 1

----------------------------------------
Command "/usr/local/Cellar/pypy/4.0.1/bin/pypy -u -c "import setuptools, tokenize;__file__='/private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-fCQrIA-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-build-RBCHFE/numpy

And when I am trying to follow instructions from http://pypy.org/download.html I get even more confusing error about pypy version 4.1:

Cloning https://bitbucket.org/pypy/numpy.git to /var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-59hKzA-build
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-59hKzA-build/setup.py", line 33, in <module>
    ('.'.join(map(str, MIN_PYPY_VERSION)),))
RuntimeError: PyPy version >= 4.1 required

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /var/folders/9p/_t441dx15ddcx5ycrjxrxmyh0000gn/T/pip-59hKzA-build

Dose anyone know what am I doing wrong and how can I fix it?

Upvotes: 2

Views: 2047

Answers (1)

otterb
otterb

Reputation: 2710

NumPy is being ported to pypy and so only an experimental version is available for now. According to the official site, the command to install that version of NumPy to pypy is:

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

http://pypy.org/download.html#installing-numpy

The command you tried will probably try to install normal NumPy from PyPI which is not ready for pypy.

(edit)

I just followed the instructions given at https://bitbucket.org/pypy/numpy and I could install numpy 1.9.0 to pypy on Linux Mint 17.

Basically create a new env for pypy-numpy

virtualenv -p /path/to/pypy/bin/pypy /directory/to/try/pypy-numpy

/path/to/pypy/bin/pypy here is the path to your PyPy 4.0.1. /directory/to/try/pypy-numpy is up to you. I created in home/pypy-numpy

Then I cloned NumPyPy source by

git clone https://bitbucket.org/pypy/numpy.git

then I moved to this clone directory 'numpy' and did

git checkout pypy-4.0.1

This fetched the version of NumPyPy we need for PyPy 4.0.1

Now I can

~/pypy-numpy/bin/pypy setup.py install

which worked without problems.

Hope this helps on Mac as well.

Upvotes: 4

Related Questions