I'm not quite sure this question belong to StackOverflow and not other SE website, but since it's python related I thought it might fit.
Recently, I started getting error in my IDE (details on my IDE below) - I get an error "cannot find reference 'path' in 'os.py'" Looking into os.py, I realize that os.path is just an alias for posixpath.py (on Linux) or ntpath.py (on Windows). Now, no change has been made to my python installation, and when running scripts that import os.path (or from it), they all run fine, so there is no actual error, just annoying warning in my IDE. I tried changing the project interpreter in the IDE and it didn't work. I also tried running from terminal with the said IDE, and it worked fine. Could it be a bug in PyCharm?
I looked online and couldn't find bug report or anyone struggling with the same problem.
PyCharm build details:
PyCharm 2018.1 (Community Edition) Build #PC-181.4203.547, built on March 26, 2018 JRE: 1.8.0_152-release-1136-b20 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.7.0-0.bpo.1-amd64
It's a bug that was fixed in 2018.1.1 https://youtrack.jetbrains.com/issue/PY-28764
I suppose it is a bug (or behavior) introduced in the very last version of PyCharm. Indeed, it has been happening to me since the last update I recently installed.
However, I temporary ignored these unresolved references in PyCharm to avoid the annoying and misleading warnings.
To do so, if you are importing os.path
this way (e.g.):
from os.path import join
Go to PyCharm preferences -> Editor -> Inspections
Then, look for "Unresolved references" under "Python" and add the following entries:
Hope this helps, Giuliano
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With