破碎的PyCharm口译员

时间:2014-03-15 00:11:39

标签: python pycharm

我一直在使用PyCharm CE取得了相当大的成功。但我刚刚安装了底图模块(必须从源代码编译地理位置和底图),它似乎打破了PyCharm解释器。当我从终端运行Python时,我的所有模块都正确加载,当我从终端WITHIN PyCharm运行Python时,我的所有模块都正常运行,但现在当我尝试从交互式解释器加载某些包时,我收到错误消息。例如,现在当我尝试在交互式解释器中导入pandas时,我得到了这个:

Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-3-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
import pandas.core.config_init
File "/Library/Python/2.7/site-packages/pandas/core/config_init.py", line 4, in <module>
from pandas.core.format import detect_console_encoding
File "/Library/Python/2.7/site-packages/pandas/core/format.py", line 12, in <module>
from pandas.core.index import Index, MultiIndex, _ensure_index
File "/Library/Python/2.7/site-packages/pandas/core/index.py", line 10, in <module>
import pandas.index as _index
File "index.pyx", line 34, in init pandas.index (pandas/index.c:14957)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-        packages/pytz/__init__.py", line 31, in <module>
from pkg_resources import resource_stream
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/pkg_resources.py", line 2717, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/pkg_resources.py", line 682, in subscribe
callback(dist)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/pkg_resources.py", line 2717, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/pkg_resources.py", line 2255, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/pkg_resources.py", line 1851, in declare_namespace
path = sys.modules[parent].__path__
KeyError: 'dap'

如果我再次尝试导入pandas,则会在同一会话中将错误消息更改为:

Traceback (most recent call last):
cannot import name hashtable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-6-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable

我怎么做才能打破翻译?我尝试重新安装PyCharm进行重置,但似乎无法正常工作。

1 个答案:

答案 0 :(得分:0)

我的情况这对任何人都有帮助。我在Django项目中遇到了这个问题,该项目也设置为使用Google App Engine;因此,PyCharm加载了许多Python包的GAE版本(它们被添加到我的PYTHONPATH中)。我在文件中禁用了Google App Engine支持 - &gt;设置 - &gt;语言与框架 - &gt; Google App Engine。问题消失了。

注意:在PyCharm之外运行我的Django应用程序时,我没有Pandas导入问题。