I am using PyCharm to work on a project. The project is opened and configured with an interpreter, and can run successfully. The remote interpreter paths are mapped properly. This seems to be the correct configuration, but PyCharm is highlighting my valid code with "unresolved reference" errors, even for built-in Python functions. Why don't these seem to be detected, even though the code runs? Is there any way to get PyCharm to recognize these correctly?
This specific instance of the problem is with a remote interpreter, but the problem appears on local interpreters as well.
I finally got this working after none of the proposed solutions worked for me. I was playing with a django rest framework project and was using a virtualenv I had setup with it. I was able to get Pycharm fixed by marking the root folder as the sources root, but then django's server would throw resolve exceptions. So one would work when the other wouldn't and vice versa.
Ultimately I just had to mark the subfolder as the sources root in pycharm. So my structure was like this
That second playground folder is the one I had to mark as the sources root for everything to work as expected. That didn't present any issues for my scenario so it was a workable solution.
Just thought I'd share in case someone else can use it.
Are you using virtualenv?
if so, you need to notify PyCharm for every change in the location of the the desired python.exe (merely ./activate is not enough for PyCharm)
Make sure Pycharm points to the correct interpetor and packages: File -> Settings -> Project -> Project Interpreter. Click the gear and choose python.exe under virtualenv's Scripts folder
Geeze what a nightmare, my amalgamation of different StackOVerflow answers:
You might try closing Pycharm, deleting the
.idea
folder from your project, then starting Pycharm again and recreating the project. This worked for me whereas invalidating cache did not.File | Invalidate Caches... and restarting PyCharm helps.
If you are using
vagrant
the error can be caused by wrong python interpreter. In ourvagrant
we are usingpyenv
so I had to changePython Interpreter path
path from/usr/bin/python
to/home/vagrant/.pyenv/versions/vagrant/bin/python