一、背景
PyCharm执行Python时,找不到自己安装的package,例如pandas、numpy、scipy、scikit等,在执行时报如下错误ImportError: No module named pandas:
Traceback (most recent call last): File "<input>", line 1, in <module> File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import module = self._system_import(name, *args, **kwargs) ImportError: No module named pandas
二、问题解决
(1)pycharm添加Python interpreter;
(2)给添加的Python interpreter添加自已安装的package路径。
1、pycharm添加Python interpreter
打开项目设置(pycharm–>preference)
添加interpreter,选中本地python命令所在目录,注意保持1和2中的interpreter一致
2、给添加的Python interpreter添加自已安装的package路径
选中刚才添加的interpreter,然后单击底部的”show paths for the selected interpreter”按钮,添加自己安装的package,例如pandas、numpy、scipy、scikit等。
单击底部的”+”号,添加自己安装的package的路径
获取package路径
~ python Python 2.7.10 (default, Jul 15 2017, 17:16:57) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin Type "help", "copyright", "credits" or "license" for more information. > import pandas > print pandas <module 'pandas' from '/Library/Python/2.7/site-packages/pandas/__init__.pyc'>
三、补充
查看当前python interpreter执行时加载的package路径
输入命令sys.path
Out[3]: ['/Applications/PyCharm.app/Contents/helpers/pydev', '/Library/Python/2.7/site-packages/scikit_learn-0.19.1-py2.7-macosx-10.13-intel.egg/sklearn/model_selection', '/Library/Python/2.7/site-packages/scikit_learn-0.19.1-py2.7-macosx-10.13-intel.egg', '/Library/Python/2.7/site-packages/scikit_learn-0.19.1-py2.7-macosx-10.13-intel.egg/sklearn', '/Library/Python/2.7/site-packages', '/Applications/PyCharm.app/Contents/helpers/pydev', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg', '/Library/Python/2.7/site-packages/jupyter-1.0.0-py2.7.egg', '/Library/Python/2.7/site-packages/qtconsole-4.3.1-py2.7.egg', '/Library/Python/2.7/site-packages/notebook-5.4.1-py2.7.egg', '/Library/Python/2.7/site-packages/nbconvert-5.3.1-py2.7.egg', '/Library/Python/2.7/site-packages/jupyter_console-5.2.0-py2.7.egg', '/Library/Python/2.7/site-packages/ipywidgets-7.1.2-py2.7.egg', '/Library/Python/2.7/site-packages/terminado-0.8.1-py2.7.egg', '/Library/Python/2.7/site-packages/nbformat-4.4.0-py2.7.egg', '/Library/Python/2.7/site-packages/Jinja2-2.10-py2.7.egg', '/Library/Python/2.7/site-packages/Send2Trash-1.5.0-py2.7.egg', '/Library/Python/2.7/site-packages/testpath-0.3.1-py2.7.egg', '/Library/Python/2.7/site-packages/pandocfilters-1.4.2-py2.7.egg', '/Library/Python/2.7/site-packages/mistune-0.8.3-py2.7.egg', '/Library/Python/2.7/site-packages/entrypoints-0.2.3-py2.7.egg', '/Library/Python/2.7/site-packages/bleach-2.1.3-py2.7.egg', '/Library/Python/2.7/site-packages/widgetsnbextension-3.1.4-py2.7.egg', '/Library/Python/2.7/site-packages/jsonschema-2.6.0-py2.7.egg', '/Library/Python/2.7/site-packages/MarkupSafe-1.0-py2.7-macosx-10.13-intel.egg', '/Library/Python/2.7/site-packages/configparser-3.5.0-py2.7.egg', '/Library/Python/2.7/site-packages/html5lib-1.0.1-py2.7.egg', '/Library/Python/2.7/site-packages/functools32-3.2.3.post2-py2.7.egg', '/Library/Python/2.7/site-packages/webencodings-0.5.1-py2.7.egg', '/Library/Python/2.7/site-packages/pyltp-0.1.10-py2.7-macosx-10.13-intel.egg', '/Library/Python/2.7/site-packages/Send2Trash-1.5.0-py2.7.egg', '/Library/Python/2.7/site-packages/pandocfilters-1.4.2-py2.7.egg', '/Library/Python/2.7/site-packages/functools32-3.2.3.post2-py2.7.egg', '/Users/zjw94377/venv/bus/lib/python27.zip', '/Users/zjw94377/venv/bus/lib/python2.7', '/Users/zjw94377/venv/bus/lib/python2.7/plat-darwin', '/Users/zjw94377/venv/bus/lib/python2.7/plat-mac', '/Users/zjw94377/venv/bus/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/zjw94377/venv/bus/lib/python2.7/lib-tk', '/Users/zjw94377/venv/bus/lib/python2.7/lib-old', '/Users/zjw94377/venv/bus/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/zjw94377/venv/bus/lib/python2.7/site-packages', '/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend', '/Library/Python/2.7/site-packages/IPython/extensions']
以上这篇mac PyCharm添加Python解释器及添加package路径的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线
暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。
艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。
《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。