I am trying to import numpy
in Cygwin. I get the following error message.
I have numpy 1.11.2-1
, a.k.a. the python2-numpy: Python scientific computing module
package, installed through the Cygwin installer. I also have Python 2.7.14-1
, a.k.a. the python2: Python 2 language interpreter
package also installed through Cygwin. I don't have a local installation of Python on my machine.
$ python
Python 2.7.14 (default, Oct 31 2017, 21:12:13)
[GCC 6.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", 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 8, in <module>
from .type_check import *
File "/usr/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: No such file or directory
cygcheck
:
$ cygcheck -c python2-numpy
Cygwin Package Information
Package Version Status
python2-numpy 1.11.2-1 OK
Also, I was able to import numpy
in Cygwin
on another computer.
There seem to be a number of posts on this but all lacking a solution that works for me. I tried restarting my computer per Not able to import numpy in cygwin, but that did not work.
I have also edited my $PATH
variable:
$ echo $PATH
/usr/lib/python2.7/site-packages/numpy/:/usr/lib/python2.7/site-packages/:/usr/bin
The solution:
$ PATH=/usr/lib/lapack:$PATH
Numpy is unable to load the BLAS library, probably as the PATH was redefined to NOT include /usr/lib/lapack
or you are not using bash or csh.
$ 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
For avoiding collision the NETLIB BLAS shared library is under /usr/lib/lapack
and the scripts in /etc/profile.d/
add that directory to the PATH
$ cat /etc/profile.d/lapack0.sh
LA_PREFIX=/usr
LA_LIBDIR=${LA_PREFIX}/lib
LA_BINDIR=${LA_LIBDIR}/lapack
# Check if the PATH variable is empty or not
if test -n "${PATH}"; then
# PATH is not empty
# Check if path is already in PATH
if ! /bin/echo ${PATH} | /bin/grep -q "${LA_BINDIR}" ; then
# Path is not already in PATH, append it to PATH
export PATH="${PATH}:${LA_BINDIR}"
fi
else
# PATH is empty
export PATH="${LA_BINDIR}"
fi
unset LA_PREFIX
unset LA_LIBDIR
unset LA_BINDIR