而从PyCharm运行没有

而从PyCharm运行没有

本文介绍了Python:从cygwin运行工程,而从PyCharm运行没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用

from sklearn.cluster import DBSCAN

从64位cygwin终端提示符使用python 2.7的64位版本。

from the 64 bit cygwin terminal prompt which uses a 64bit build of python 2.7.

当我从64位和32位pycharm与 -vv 解释器选项运行相同,我得到(前两行是详细输出):

When I run the same from both 64 bit and 32 bit pycharm with -vv interpreter options, I get (the first 2 lines are the verbose output):

import numpy.linalg.linalg # precompiled from /usr/lib/python2.7/site-packages/numpy/linalg/linalg.pyc
dlopen("/usr/lib/python2.7/site-packages/numpy/linalg/lapack_lite.dll", 2);
Traceback (most recent call last):
  File "C:/Users/mack0242/Dropbox/PhD/scripts/cluster.py", line 5, in <module>
    from sklearn.cluster import DBSCAN
  File "/usr/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "/usr/lib/python2.7/site-packages/sklearn/base.py", line 9, in <module>
    import numpy as np
  File "/usr/lib/python2.7/site-packages/numpy/__init__.py", line 170, 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 19, 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

我已经双重检查和文件:

I have double checked and the file:

/usr/lib/python2.7/site-packages/numpy/linalg/lapack_lite。 dll

存在且为64位。

此外,PyCharm说没有名为 sklearn 的模块,因此我已经在cygwin终端上成功安装了numpy,scipy和sklearn c $ c>, matplotlib numpy

Additionally, PyCharm says there are no modules named sklearn, matplotlib and numpy.

推荐答案

当我有一个类似的问题(无法导入numpy在Pycharm但在cygwin控制台),结果是cygwin使用不同的解释器PyCharm。

When I had a similar problem (couldn't import numpy in Pycharm but on cygwin console), it turned out that cygwin was using a different interpreter as PyCharm.

在PyCharm中,我从 C:\Program Files\cygwin\usr\bin\python 配置了解释器。相反,cygwin使用 / bin / python 。在PyCharm中,单击文件>设置>项目:yourProjectName>项目解释器,单击添加本地并找到cygwin使用的解释器(在我的情况下 C: Program Files \cygwin\bin\python )。

In PyCharm I had configured the interpreter from C:\Program Files\cygwin\usr\bin\python. In contrast, cygwin was using /bin/python. In PyCharm click File > Settings > Project: yourProjectName > Project Interpreter, click on "Add local" and find the interpreter used by cygwin (in my case C:\Program Files\cygwin\bin\python).

然后通过查看在PyCharm中打开Python控制台>工具Windows> Python控制台并尝试导入语句。

Then open the Python Console in PyCharm via View > Tools Windows > Python Console and try your import statement.

这篇关于Python:从cygwin运行工程,而从PyCharm运行没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 20:31