pythonCan不能在Pycharm中导入模块,而我可以在终端中导入相同的模块?

2024-04-28 09:47:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我安装了essentia brew install essentia --HEAD 信息: Python modules have been installed and Homebrew's site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run: mkdir -p /Users/yangyy/Library/Python/2.7/lib/python/site-packages echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/yangyy/Library/Python/2.7/lib/python/site-packages/homebrew.pth

我按照消息的指示进行了操作,并成功地安装了essentia。 可在终端导入模块: Python 2.7.11 (default, Feb 23 2016, 00:59:46) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. -import essentia -exit() $ which python /usr/local/bin/python

我用Pycharm作为我的IDE。我试了所有的解释器,但还是不能导入这个模块。在

在python中,我尝试了:

>>> import essentia
>>> reload(essentia)
<module 'essentia' from '/usr/local/lib/python2.7/site-packages/essentia/__init__.pyc'>

Tags: installedtoimportyoumoduleslibpackagesusr
1条回答
网友
1楼 · 发布于 2024-04-28 09:47:03

Pycharm不会接受包依赖项,而是包含您应该为项目启动的包。。 所以,为了这个,你应该去

settings -> project Interpreter 

然后选择你的项目,检查你的包在那里,然后点击

^{pr2}$

就是这样

相关问题 更多 >