Dependencies added by setup.py install/develop don't support code completion

Hi, so this is a problem I have noticed recently with the IntelliJ Python Plugin, and I assume the same problem exists for PyCharm as well. I wasn't sure which discussion group to mention this in, but I assume people here are more Python-savy than the regular IntelliJ community forum.

Basically, if I have a virtualenv and I pip install some dependencies, and then set the intrepreter in the virtualenv's bin directory as the project's interpreter, the IDE has no problems finding and indexing all of the files that need to be indexed for autocomplete to work. If you go into the site-packages directory of the virtualenv that you are using, you will find two directories: a directory for the package (assuming the package was in a directory and not just a single python file) and a directory for the EGG-INFO.

This is nice, but there are problems with this style of development, so I have recently started adding setup.py to each of my python projects and managing dependencies with setup.py's "install_requires" instead. I use the configuration manager to create run instructions for setup.py develop/install (in PyCharm, I think this is built-in now) and execute the "setup.py develop" so it will install the packages. This creates a bunch of .egg directories that contain two directories, the package directory and the directory for the EGG-INFO. This is subtly different from above in that it creates a .egg directory and inside it is the package and the EGG-INFO, they aren't just sitting in the site-packages by themselves.

This works great from a development perspective, but the problem is the IDE will no longer support code completion for packages installed in this manner, even though the packages are perfectly fine and if I were to run the application, everything is in scope. The IDE won't even recognize the library as being installed as all (if I include Flask as a dependency and do setup.py install/develop, it won't ask to autocomplete "from flask.app import Flask" if I make a call to "Flask()"), even though I can see in the External Libraries > site-packages all the eggs for the libraries in it from IntelliJ. The IDE will report that it is indexing if I add a new dependency to the setup.py and run "python setup.py develop", but the indexing is shorter than normal, and I assume it does pretty much nothing other than noticing the egg's existence, and never finds the package within.

Has anyone else ever had this issue and come up with a good solution to this? Thanks.

3 comments
Comment actions Permalink

A year late but just ran into this and found a workaround.

My setup consists of: PyCharm 2016.3 on macOS, a python 3.5 virtualenv through conda with various packages installed through conda / pip.

I had a local package I was developing installed into this virtualenv through "python setup.py develop" and PyCharm wouldn't recognize the package (didn't show any code completion, etc..) but I could run my project and it all worked as expected with the package installed in develop mode (the package could be found and used in my code).

To fix it I went to my project settings in the PyCharm GUI and installed a python package (in this case I just picked Flask and installed it) and then I uninstalled the package using the GUI. Then PyCharm would recognize my locally installed project in develop mode again and code completion works.

2
Comment actions Permalink

The PyCharm 'install extra package through GUI' trick worked for me. (Deinstallation was not required).

Other than python 2.7 (and not 3.5), my local setup is the same.

 

1
Comment actions Permalink

Seems like this has been fixed. You just need to invalidate the cache and restart. 

P

0

Please sign in to leave a comment.