Como instalar numpy no Python 2.7 em virtualenv?

0

Estou tentando instalar numpy em Python 2.7 em virtualenv (no Cygwin).
No entanto, quando tento import numpy , obtenho um ImportError :

Administrator@Ron ~/python/virtualenv
$ virtualenv -p /usr/bin/python2.7.exe machine_learning
Running virtualenv with interpreter /usr/bin/python2.7.exe
New python executable in /home/Administrator/python/virtualenv/machine_learning/bin/python2.7
Also creating executable in /home/Administrator/python/virtualenv/machine_learning/bin/python
Installing setuptools, pip, wheel...done.

Administrator@Ron ~/python/virtualenv
$ source machine_learning/bin/activate
(machine_learning)
Administrator@Ron ~/python/virtualenv
$ pip2 install numpy
Collecting numpy
Installing collected packages: numpy
Successfully installed numpy-1.13.0
(machine_learning)
Administrator@Ron ~/python/virtualenv
$ python2 -c "import numpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/lib/__init__.py", line 19, in <module>
    from .polynomial import *
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 20, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 51, in <module>
    from .linalg import *
  File "/home/Administrator/python/virtualenv/machine_learning/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 30, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: No such file or directory
(machine_learning)
Administrator@Ron ~/python/virtualenv

Alguma sugestão de como instalar o numpy no Python 2.7 em virtualenv?

Nota:
A versão Python3 do Cygwin é 3.6, e parece que o pypi numpy ainda não está pronto para o 3.6.

Editar 1:

Em resposta ao comentário do matzeri , desinstalei o numpy do pip3 e do pip2 e instalei o numpy para Python 3 e Python 2 do setup.exe do Cygwin.
A seguir estão os erros que recebo para numpy quando tento importá-lo depois:

$ python3 -c "import numpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib/python3.6/site-packages/numpy/lib/__init__.py", line 18, in <module>
    from .polynomial import *
  File "/usr/lib/python3.6/site-packages/numpy/lib/polynomial.py", line 20, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/usr/lib/python3.6/site-packages/numpy/linalg/__init__.py", line 51, in <module>
    from .linalg import *
  File "/usr/lib/python3.6/site-packages/numpy/linalg/linalg.py", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: No such file or directory

$ python2 -c "import numpy"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
    from .polynomial import *
  File "/usr/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 20, in <module>
    from numpy.linalg import eigvals, lstsq, inv
  File "/usr/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 51, in <module>
    from .linalg import *
  File "/usr/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
    from numpy.linalg import lapack_lite, _umath_linalg
ImportError: No such file or directory
    
por boardrider 20.06.2017 / 13:06

1 resposta

0

Instale o pacote python2-numpy com a configuração do cygwin. Você não precisa pip para instalá-lo.

python2 -c "import numpy" funciona para mim.
Como o problema parece estar em lapack_lite , verifique se você tem /usr/lib/lapack/ em seu caminho.

$ cygcheck -l liblapack0
/etc/profile.d/lapack0.csh
/etc/profile.d/lapack0.sh
/usr/lib/lapack/cygblas-0.dll
/usr/lib/lapack/cyglapack-0.dll


 $ cygcheck /usr/lib/python2.7/site-packages/numpy/linalg/lapack_lite.dll | grep -v Windows
E:\cygwin64\lib\python2.7\site-packages\numpy\linalg\lapack_lite.dll
  E:\cygwin64\bin\cygwin1.dll
  E:\cygwin64\lib\lapack\cyglapack-0.dll
    E:\cygwin64\bin\cyggcc_s-seh-1.dll
    E:\cygwin64\bin\cyggfortran-3.dll
      E:\cygwin64\bin\cygquadmath-0.dll
    E:\cygwin64\bin\cygblas-0.dll
  E:\cygwin64\bin\libpython2.7.dll

Caso contrário, a biblioteca de lapelas não funcionará.

    
por 20.06.2017 / 22:15