PyCharm 5.0.1 doesn't resolve builtin modules / methods

烈酒焚心 提交于 2019-12-06 06:49:44

问题


My PyCharm 5.0.1 installation does not resolve references to any builtin modules or methods:

As you can see, I have installed python over cygwin.

I already tried:

  • reinstalling / updating the python installation (from 2.7.9 to 2.7.10)
  • reinstalling pycharm
  • adding a interpreter path to the python-skeletons in the pycharm installation directory (this was immediately removed by the ide when saving the settings, implying, that it already is embedded)
  • removing the interpreter (this removes the warnings, but also the code completion, and import asdflkjasd is valid as well)
  • adding various paths like /lib/python2.7/site-packages/ to the interpreter packages option

None of these improved the situation. How can I fix this without installation outside of cygwin alltogether?


回答1:


This is an update with a much better solution than my previous answer (which I completely missed that OP was asking for a solution that didn't require exactly what I suggested).

Like Carl commented above, updating python-skeletons is actually the way to go, however, if you're using Cygwin, the interpreter paths are a little wonky, and PyCharm won't always automatically add the right paths. For me, PyCharm handled it just fine in version 4.5.4, but not 5.0.4.

You'll find the python builtins in your Pycharm config directory, probably at:

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

Just manually add this path (or paths) to your interpreter and it should resolve your problem. You can do the same for your site-packages folder if that's currently polluting your project structure space.

To get to the right menu:

  1. Click File -> Settings
  2. Navigate to Project -> Project Interpreter
  3. Click the gear on the top right and click "More"
  4. Select your interpreter and click the "Show paths" button on the right
  5. Instead of clicking refresh, as many other posts suggest, click the "Add" button on the right and add your paths

There's a handy screenshot uploaded by r---------k on the updating python-skeletons post that if that helps you.

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.




回答2:


I use Windows 10 x64, Python 3.5.1 and PyCharm Community Edition 2016.1.4

I have the same problem and sovled it by runnig PyCharm in admin mode (it is required only once).



来源:https://stackoverflow.com/questions/33700328/pycharm-5-0-1-doesnt-resolve-builtin-modules-methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!