3

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

enter image description here

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?

Community
  • 1
  • 1
Zulakis
  • 7,859
  • 10
  • 42
  • 67
  • Have you set the interpreter for this specific project in the settings to the correct python instance? – Dan Nov 13 '15 at 19:27
  • It is set to the python2.7.exe interpeter (also seen in the left sidebar on the screenshot) – Zulakis Nov 13 '15 at 19:29
  • See [this](http://stackoverflow.com/a/33318875/868044) – Dan Nov 13 '15 at 19:31
  • @Dan Yeah, I found that one already. I set the interpreter in the way described. I the python console the import statements and the inbuilt methods to work. The same interpreter also works in cygwin. Actually, I just found out, resolving methods in `/lib/python2.7/(site-packages)` does work if I add this to the path manually. However, any inbuilt function or functions in `/lib/python2.7/lib-dynload` don't. – Zulakis Nov 13 '15 at 19:34
  • Currently I am on 5.0.2 and this resolved the same issue for me, [updating python-skeletons](http://stackoverflow.com/questions/11725519/pycharm-shows-unresolved-references-error-for-valid-code/20022329#20022329). – Carl Dec 14 '15 at 14:04

2 Answers2

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.

Community
  • 1
  • 1
Alvin Siu
  • 75
  • 1
  • 3
1

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).

Maks
  • 2,808
  • 4
  • 30
  • 31
  • This absolutely solved my problem compared to the 100 solutions I have tried so far. I recommend this for Windows users!!!. Thank you! – stormfield Jul 12 '20 at 22:38