PyCharm 5.0.1不解析内置模块/方法

2024-04-26 10:31:44 发布

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

我的PyCharm 5.0.1安装不会解析对任何内置模块或方法的引用:

enter image description here

如您所见,我已经在cygwin上安装了python。在

我已经试过了:

  • 重新安装/更新python安装(从2.7.9到2.7.10)
  • 重新安装pycharm
  • 向pycharm安装目录中的python骨架添加一个解释器路径(在保存设置时,ide立即将其删除,这意味着它已经被嵌入)
  • 删除解释器(这会删除警告,但也会删除代码完成,并且import asdflkjasd也是有效的)
  • 向解释器包选项添加各种路径,如/lib/python2.7/site-packages/

这些都没有改善局势。 如果没有cygwin之外的安装,我如何修复这个问题?在


Tags: 模块方法代码import路径目录警告ide
2条回答

这是一个比我之前的答案更好的解决方案的更新(我完全忽略了OP所要求的解决方案并不完全需要我的建议)。在

正如Carl在上面评论的,updating python-skeletons实际上是一种方法,但是,如果您使用Cygwin,解释器路径有点不稳定,PyCharm不会总是自动添加正确的路径。对我来说,PyCharm在4.5.4版本中处理得很好,但在5.0.4版本中处理得不好。在

您可以在Pycharm config目录中找到python内置函数,可能位于:

C:\Users\[USERNAME]\.PyCharm50\system\python_stubs\-[RANDOM_STRING_OF_NUMBERS]

只需手动将这个路径(或多个路径)添加到解释器中,它就可以解决您的问题。如果站点包文件夹当前正在污染项目结构空间,则可以对其执行相同的操作。在

右键进入菜单:

  1. 单击文件->设置
  2. 导航到“项目”->;“项目解释器”
  3. 单击右上角的齿轮,然后单击“更多”
  4. 选择您的解释器并单击右侧的“显示路径”按钮
  5. 不要像其他帖子建议的那样点击刷新,而是点击右边的“添加”按钮,添加你的路径

updating python-skeletons的帖子上有一个handy screenshotr -k上传,如果这对你有帮助的话。在

Try installing the Python package for Windows from http://www.python.org/download/windows and point PyCharm to that interpreter instead.

Settings -> Project -> Project Interpreter -> Gear -> Add Local

You may also need to install PyCharm's Python packaging tools (you should see a link on the bottom of the Project Interpreter page if it isn't installed already).

While this may not be a perfect solution depending on your workflow because PyCharm will no longer be using Cygwin's python interpreter, but this at least got rid of those pesky squiggly red underlines for me.

我使用Windows 10 x64、Python 3.5.1和PyCharm社区版2016.1.4

我也遇到了同样的问题,在管理模式下运行PyCharm解决了这个问题(只需要一次)。在

相关问题 更多 >