尽管更改了 pyCharm python 解释器路径,但无法将 Pandas 导入 pycharm 解释器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28640911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 22:57:53  来源:igfitidea点击:

Can't import pandas into pycharm interpreter, despite changing pyCharm python interpreter path

pythonpandaspycharm

提问by Hillary Sanders

I'm trying to import pandas in the pyCharm python interpreter, but I keep on getting the dreaded

我正在尝试在 pyCharm python 解释器中导入Pandas,但我一直在害怕

>>> import pandas
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: No module named pandas

It works fine when I run python from the terminal. I've read up on solutions for this, but none have worked so far. I've pip uninstalled, reinstalled, and updated pandas. I've changed the pyCharm project python interpreter and default pyCharm python interpreter to be "2.7.5 (/usr/local/bin/python)", so that now:

当我从终端运行 python 时它工作正常。我已经阅读了有关此问题的解决方案,但到目前为止都没有奏效。我已经卸载、重新安装和更新了 Pandas。我已将 pyCharm 项目 python 解释器和默认 pyCharm python 解释器更改为“2.7.5 (/usr/local/bin/python)”,因此现在:

>>> os.system('which python')
/usr/local/bin/python

occurs in the pycharm interpreter and terminal python interpreter.

发生在 pycharm 解释器和终端 python 解释器中。

Any more ideas on how to fix this?

关于如何解决这个问题的更多想法?

Thanks

谢谢

回答by Hillary Sanders

Turns out, changing my terminal shell path in pyCharms settings (In the menu bar, pyCharm --> Preferences --> tools --> terminal --> Shell Path) to the correct thing:

事实证明,将 pyCharms 设置(在菜单栏中,pyCharm --> Preferences --> tools --> terminal --> Shell Path)中的终端 shell 路径更改为正确的内容:

> echo $PATH # whatever this spits out in terminal is your shell path

fixed everything :)

固定一切:)

回答by dushshantha

I changed the project interpreter under PyCharm -> Preferences -> Project -> Project Interpreter to the one that that of my system uses. I had 2.6 and 2.7 in the system and PyCharm was using 2.6 by default. Changed it to 2.7 which is what the Terminal was using. Problem solved.

我将 PyCharm -> Preferences -> Project -> Project Interpreter 下的项目解释器更改为我系统使用的解释器。我在系统中有 2.6 和 2.7,而 PyCharm 默认使用 2.6。将其更改为 2.7,这是终端使用的。问题解决了。