PyCharm shows unresolved references error for vali

2019-01-01 06:52发布

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.

18条回答
时光乱了年华
2楼-- · 2019-01-01 06:58

None of the above solutions worked for me!
If you are using virtual environment for your project make sure to apply the python.exe file that is inside your virtual environment directory as interpreter for the project (Alt + Ctrl + Shift + S) this solved the issue for me.

查看更多
只靠听说
3楼-- · 2019-01-01 07:06

In my case it was the directories structure. My project looks like this:

+---dir_A
    +---dir_B
        +app
        |
        \-run.py

So right click on dir_b > "mark directory as" > "project root"

查看更多
裙下三千臣
4楼-- · 2019-01-01 07:06

Sorry to bump this question, however I have an important update to make.

You may also want to revert your project interpreter to to Python 2.7.6 if you're using any other version than that This worked for me on my Ubuntu installation of PyCharm 4.04 professional after none of the other recommendations solved my problem.

查看更多
大哥的爱人
5楼-- · 2019-01-01 07:07

It could also be a python version issue. I had to pick the right one to make it work. enter image description here

查看更多
路过你的时光
6楼-- · 2019-01-01 07:08

If none of the other solutions work for you, try (backing up) and deleting your ~/.PyCharm40 folder, then reopening PyCharm. This will kill all your preferences as well.

On Mac you want to delete ~/Library/Caches/Pycharm40 and ~/Library/Preferences/PyCharm40.

And on Windows: C:\Users\$USER.PyCharm40.

查看更多
路过你的时光
7楼-- · 2019-01-01 07:09

Dmitry's response didn't work for me.

I got mine working by going to Project Interpreters, Selecting the "Paths" tab, and hitting the refresh button in that submenu. It auto-populated with something called "python-skeletons".

edit: screenshot using PyCharm 3.4.1 (it's quite well hidden)

enter image description here

查看更多
登录 后发表回答