Closed djbucci closed 7 years ago
I actually get code completion in a virtualenv. Did you get any output or warning while starting gedit in virtualenv?
It seems like python plugins in gedit only works if you create virtualenv with --system-site-packages
otherwise the plugin just don't load. It complains about the gi
package being missing. I tried to install required packages with pip
but it caused other errors. But I was able to run gedit after creating a symlink to system package in virtualenv. So what I did was:
ln -s /usr/lib64/python3.5/site-packages/gi $VIRTUAL_ENV/lib/python3.5/site-packages/
The gi
path can change according to your distro. It can be placed in dist-packages
folder or look for python packages under /usr/lib
instead of /usr/lib64
.
Then you can run gedit in that virtualenv. Also you need to install jedi with pip:
pip install jedi
Another way to get things right as I mentioned in first sentence is creating your virtualenv with --system-site-packages
parameter. But if you want to isolate your virtualenv fully, use the solution above.
Can you confirm it runs with this settings?
So the plugin itself definitely runs both in a virtualenv and in the base system env. To get it to work initially, I used the symbolic linking of gi from site-packages into the virtualenv as you specified. Once it actually activates in gedit, the console output in the terminal looks like this
Gedi is activated.
(gedit:8984): Gtk-CRITICAL **: gtk_widget_get_preferred_width_for_height: assertion 'height >= 0' failed
(gedit:8984): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width 10 and height -27
The two Gtk errors show up as soon as the first context menu appears. I'm pretty sure though that those are unrelated to the code completion with packages.
I actually just looked around a little, and I think it has to do with the fact that my virtualenv is Python2.7. For example, if I try to tab complete based on a package installed into the OS environment defined at /usr/lib/python2.7, gedi does not tab complete. It does however tab complete for all of the packages installed in /usr/lib/python3. Does that make sense?
Thanks again for your help.
I tried a few things to get it work with python2 packages but it failed. I looked into jedi-vim plugin and as far as I understand it uses python2 to start jedi when python2 support is needed. Gedit3+ extensions only works with python3, so there is no way to start extension in python2 which makes completion impossible.
Is there a way to get Gedi to read the site-packages based on the currently activated python virtualenv? The natural idea of running gedit from within the virtualenv doesn't seem to recognize the virtualenv's site-packages.