Python 导入错误:没有名为“瓶子”的模块 - PyCharm
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26069254/
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
ImportError: No module named 'bottle' - PyCharm
提问by Tinno TL
I installed bottle on python3.4 with pip install. In terminal, when I do:
我使用 pip install 在 python3.4 上安装了瓶子。在终端中,当我这样做时:
$ python3.4
>>>import bottle # shows no import error
>>>
but when I do it in PyCharm, it says "import bottle ImportError: No module named 'bottle'"
但是当我在 PyCharm 中执行此操作时,它显示“导入瓶导入错误:没有名为‘瓶’的模块”
采纳答案by Thomasleveil
in your PyCharm project:
在您的 PyCharm 项目中:
- press Ctrl+Alt+sto open the settings
- on the left column, select Project Interpreter
- on the top right there is a list of python binaries found on your system, pick the right one
- eventually click the
+button to install additional python modules - validate
- 按Ctrl+ Alt+s打开设置
- 在左列中,选择Project Interpreter
- 在右上角有一个在您的系统上找到的 python 二进制文件列表,选择正确的
- 最终点击
+按钮安装额外的python模块 - 证实


回答by Vinay Vemula
The settings are changed for PyCharm 5+.
PyCharm 5+ 的设置已更改。
- Go to File > Default Settings
- In left sidebar, click Default Project > Project Interpreter
- At bottom of window, click + to install or - to uninstall.
- If we click +, a new window opens where we can decrease the results by entering the package name/keyword.
- Install the package.
Go to File > Invalidate caches/restart and click Invalidate and Restart to apply changes and restart PyCharm.
回答by Ivan Talalaev
In some cases no "No module ..." can appear even on local files. In such cases you just need to mark appropriate directories as "source directories":
在某些情况下,即使在本地文件上也不会出现“No module ...”。在这种情况下,您只需要将适当的目录标记为“源目录”:




回答by Vikas Goel
I am using Ubuntu 16.04. For me it was the incorrect interpretor, which was by default using the virtual interpretor from project.
我正在使用 Ubuntu 16.04。对我来说,这是错误的解释器,默认情况下使用项目中的虚拟解释器。
So, make sure you select the correct one, as the pip install will install the package to system python interpretor.
因此,请确保选择正确的,因为 pip install 会将软件包安装到系统 python 解释器。
回答by Bruce Leat
In the case where you are able to import the module when using the CLI interpreter but not in PyCharm, make sure your project interpreter in PyCharm is set to an actual interpreter (eg. /usr/bin/python2.7) and not venv (~/PycharmProject/venv/...)
如果您能够在使用 CLI 解释器但在 PyCharm 中无法导入模块的情况下,请确保 PyCharm 中的项目解释器设置为实际解释器(例如 /usr/bin/python2.7)而不是 venv( ~/PycharmProject/venv/...)

