IntelliJ uses incorrect Python SDK for autocompletion and go-to-definition

I use IntelliJ to work on multiple separate Python modules within the same codebase. They are all using the Serverless framework, so all of their dependencies are correctly recorded in their respective Pipfiles. I have configured a module for each of them by doing "import form existing sources", and then IntelliJ prompted me to create a pipenv for each one - which I did. IntelliJ then correctly added a new Python SDK for each of them - which is what I would expect.

The problem is that for the purposes of code autocompletion and for determining if a module is installed or not, IntelliJ seems to pick a random SDK and the libraries installed in it. This is very annoying when working with libraries that have recently gone through major API changes (E.g. Tensorflow, OpenCV, etc.). Also, it leads to subtler bugs where modules that haven't been installed don't get underlined in red, they only get underlined in yellow as "not in project requirements".

Also, when I command-click on the imports, if the modules are found in the correct environment, e.g. the one belonging to the IntelliJ module and generated from the Pipfile, IntelliJ automatically opens their source code. However, if IntelliJ finds them in a different environment, it only highlights the folder.

It's really weird and confusing behaviour, to say the least!

1
1 comment

I have the same problem here, one project with multiple python modules each one with his own virtual environment, intelliJ seems that it doesn't picks up correctly the virtualenv for the modules, since it can't run any file, and dependencies that are properly set up are marked in red.

0

Please sign in to leave a comment.