How to enable PyCharm to find unresolved references and documentation? Follow
Hi.
I am concerned with the situations in which the PyCharm editor is not intelligently recognizing the Python libraries (packages) in use, or not displaying the related documentation.
I believe that there is a hugely important configuration step that I am missing across all my projects.
For example, I am working on a project that contains both a Python virtual environment generated from the requirements.txt file in the .venv folder and, the virtual environment in the venv folder that the PyCharm itself has created.
The project is able to run, although I do need to add a PYTHONPATH variable to include a project root.
When I enter: import json, below that line I can see the list of json's methods in a popup window and other things available by adding a dot . after the keyword json.
On the other hand, if I add:
import socketio
Typing
socketio.
does not present me with any automatic completions, as if this keyword is completely unknown.
In general, I seem to be missing a namespace for many Python libraries.
What should I configure in PyCharm to get the complete code coverage with automatic completion, documentation, and such?
Please sign in to leave a comment.
Hi,
If you already have an environment, creating another one is not necessary. You can simply create a new project interpreter and point it to `.venv/bin/python` (for Linux/Mac) or `.venv/Scripts/python.exe` (for Windows). If socketio package is installed in that environment, it should become available. You can check your current list of available packages in the settings: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
Generally, when you have a project with existing environment and you don't want to create a new environment, you should "File | Open" and point to that project folder.
My latest and cleanest Kubuntu 21.04 allowed me the following.
I deleted both virtual environment folders. They were never intended for redistribution.
A new .venv environment is created by PyCharm that does not inherit any system packages.
Importing from requirements.txt loads everything except socketio==0.2.1.
Socketio remains impossible to install, due to a pip error.
The pip error temporarily disables PyCharm's local package manager. Clicking twice on Install tools is required in that window, Settings > Python interpreter to return the overall functionality.
PyCharm requires ignoring this socketio in the top editor window prompt.
In the PyCharm's terminal with .venv environment magic, this command ultimately installs the requirements.
python3 -m venv .venv
PYTHONPATH is updated manually to include the project root.
Now it looks almost great 99%.
I could be wrong.
Thank you,
Is it resolved or there's still an issue? Regarding issues with packages installation, I'd recommend to check our guide and try installing from terminal for the same interpreter.
Thanks.
I have a feeling that there are issues with pip, socketio, and Pycharm, but I am able to work well now.