Cygwin:导入 numpy 错误
Cygwin: import numpy error
我正在尝试 import numpy
在 Cygwin 中。我收到以下错误消息。
我有numpy 1.11.2-1
、a.k.a。 python2-numpy: Python scientific computing module
包,通过 Cygwin 安装程序安装。我还有Python 2.7.14-1
、a.k.a。 python2: Python 2 language interpreter
包也通过 Cygwin 安装。我的机器上没有本地安装 Python。
$ 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
此外,我能够在另一台计算机上 Cygwin
中 import numpy
。
似乎有很多关于此的帖子,但都缺乏适合我的解决方案。我尝试按照 重新启动我的计算机,但那没有用。
我还编辑了我的 $PATH
变量:
$ echo $PATH
/usr/lib/python2.7/site-packages/numpy/:/usr/lib/python2.7/site-packages/:/usr/bin
解决方法:
$ PATH=/usr/lib/lapack:$PATH
Numpy 无法加载 BLAS 库,可能是因为 PATH 被重新定义为不包含 /usr/lib/lapack
或者您没有使用 bash 或 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
为避免冲突,NETLIB BLAS 共享库位于 /usr/lib/lapack
/etc/profile.d/
中的脚本将该目录添加到 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
我正在尝试 import numpy
在 Cygwin 中。我收到以下错误消息。
我有numpy 1.11.2-1
、a.k.a。 python2-numpy: Python scientific computing module
包,通过 Cygwin 安装程序安装。我还有Python 2.7.14-1
、a.k.a。 python2: Python 2 language interpreter
包也通过 Cygwin 安装。我的机器上没有本地安装 Python。
$ 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
此外,我能够在另一台计算机上 Cygwin
中 import numpy
。
似乎有很多关于此的帖子,但都缺乏适合我的解决方案。我尝试按照
我还编辑了我的 $PATH
变量:
$ echo $PATH
/usr/lib/python2.7/site-packages/numpy/:/usr/lib/python2.7/site-packages/:/usr/bin
解决方法:
$ PATH=/usr/lib/lapack:$PATH
Numpy 无法加载 BLAS 库,可能是因为 PATH 被重新定义为不包含 /usr/lib/lapack
或者您没有使用 bash 或 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
为避免冲突,NETLIB BLAS 共享库位于 /usr/lib/lapack
/etc/profile.d/
中的脚本将该目录添加到 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