我已将seaborn
升级到0.9.0
,而pycharm
似乎没什么好印象的。
在命令行上工作的脚本 无法继续执行:
import seaborn as sns
抛出以下内容:
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1664, in <module>
main()
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1658, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1068, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/git/uni/_psl/proj1/myMain.py", line 202, in <module>
import seaborn as sns
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/seaborn/__init__.py", line 17, in <module>
from .widgets import *
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/seaborn/widgets.py", line 8, in <module>
from ipywidgets import interact, FloatSlider, IntSlider
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/ipywidgets/__init__.py", line 23, in <module>
from IPython import get_ipython
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/IPython/core/crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/IPython/core/ultratb.py", line 115, in <module>
from IPython.core import debugger
File "/Users/sboesch/Library/Python/3.6/lib/python/site-packages/IPython/core/debugger.py", line 46, in <module>
from pdb import Pdb as OldPdb
File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pdb.py", line 136, in <module>
class Pdb(bdb.Bdb, cmd.Cmd):
AttributeError: module 'cmd' has no attribute 'Cmd'
感谢任何提示。
答案 0 :(得分:1)
如果您有一个与标准库模块/软件包同名的自定义模块/软件包,则可能由于PYTHONPATH
冲突而发生。 cmd
。
诀窍是PyCharm和带有Python插件的IntelliJ将项目根目录,内容根目录和源根目录添加到PYTHONPATH
,因此该脚本可能在终端中正常工作,但在IDE中执行时失败。
要对内容根目录和源根目录禁用此行为,请转至专用运行配置并取消选中选项
或右键单击项目树中的相应目录->将目录标记为->取消标记为源根。
内容根目录可以在设置|项目... |项目结构。