Python 为什么 PyCharm 的自动完成功能不适用于我安装的库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28677670/
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
Why isn't PyCharm's autocomplete working for libraries I install?
提问by Mo.
PyCharm's autocomplete isn't working for installed libraries. I have the following code:
PyCharm 的自动完成功能不适用于已安装的库。我有以下代码:
from boto.emr.connection import EmrConnection
conn = EmrConnection(aws_keys.access_key_id, aws_keys.secret_key)
I want the editor to tell me what methods I have available to me when I press ctrlspace.
我希望编辑器在我按下 时告诉我可以使用哪些方法ctrlspace。
The boto library is installed in my environment, but it doesn't seem to be detected by PyCharm. How can I set this up correctly?
boto 库安装在我的环境中,但 PyCharm 似乎没有检测到它。我该如何正确设置?
采纳答案by davidism
You've installed the 3rd-party library into a virtualenv, but PyCharm doesn't know about that by default. If nothing is specified, it will choose the system Python install as the interpreter. You need to go into the project settings and configure the interpreter to point at the virtualenv. PyCharm will then index the interpreter and allow you to autocomplete.
您已将第 3 方库安装到 virtualenv 中,但默认情况下 PyCharm 不知道这一点。如果未指定任何内容,它将选择系统 Python 安装作为解释器。您需要进入项目设置并将解释器配置为指向 virtualenv。PyCharm 然后将索引解释器并允许您自动完成。


The virtualenv may be auto-detected in the dropdown menu on the left. If it is not, click the gear to the right, click "Add local", and select /path/to/virtualenv/bin/python(or \Path\to\virtualenv\Scripts\python.exeon Windows).
可以在左侧的下拉菜单中自动检测 virtualenv。如果不是,请单击右侧的齿轮,单击“添加本地”,然后选择/path/to/virtualenv/bin/python(或\Path\to\virtualenv\Scripts\python.exe在 Windows 上)。

