Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQt5 with pyton3.3 in virtualenv #265

Closed
3e4 opened this issue Mar 30, 2014 · 19 comments
Closed

PyQt5 with pyton3.3 in virtualenv #265

3e4 opened this issue Mar 30, 2014 · 19 comments

Comments

@3e4
Copy link

3e4 commented Mar 30, 2014

Before starting: thank you for writing jedi-vim!
I have a bit trouble with completion of PyQt5.

I am running vim 7.4 on Windows 7. I use dev branch of jedi-vim and I have the python code from #31 in my .vimrc to honor the virtualenv.
In the virtualenv I have jedi and PyQt5 installed.

Now my problem:
When g:jedi#force_py_version is 2, I get completion for

import PyQ<Ctrl+Space>

but if I place a period, I get "Pattern not found".

When I set g:jedi#force_py_version = 3 it does not even come up with PyQt5. As if it wasn't there.

Could this be related to #202 ?

@davidhalter
Copy link
Owner

Please update Jedi to the latest dev branch and check again. I don't think you need the changes of #31, because they are already present in Jedi.

@davidhalter
Copy link
Owner

One of the problems may also be that VIM wasn't built with Python 3.3 support, but Python 3.2 support. We're discussing possible solutions in davidhalter/jedi#385.

@3e4
Copy link
Author

3e4 commented Mar 31, 2014

I updated to master (as of today newer than dev), but same problem.
When I remove the python code I don't get PyQt5 proposed even when g:jedi#force_py_version is 2. So it seems to me that I need it for the virtualenv to work.
Or it has to do with the python3.3/python3.2 in vim.

So I should move to PyQt4 with python 2.7 (or very old PyQt4 version which still supports 3.2) in the meantime... Thought its nice to jump into python 3.3 when starting a new project.

I will keep my self updated in the jedi forums.

@davidhalter
Copy link
Owner

I'm talking about Jedi, not jedi-vim! (The master is definitely not newer!)

@3e4
Copy link
Author

3e4 commented Mar 31, 2014

ok, created fresh virtualenv and installed jedi dev branch using

(jeditest) C:\Users\****\Documents>pip install -e git://github.com/davidhalter/jedi.git@dev#egg=jedi

And I have the same behavior as in my original post. No improvement.
One more thing I noticed: With python2 active, when I do some imports and then use d on one of the Q-commands (QMessageBox), I get a loooong backtrace with the following line at the bottom (I can post the whole backtrace if you want):

ImportError: Module use of python33.dll conflicts with this version of Python.

With pyton3 active I get:

Couldn't find any definitions for this.

If I try to use d on, lets say jedi_vim.goto, it works with pyton2 and python3.

@davidhalter
Copy link
Owner

I don't think this will ever work, because it's basically a problem of the running Python instance (which VIM defines). We should be switching to a server client architecture as in davidhalter/jedi#385, which resolves these kind of problems.

@3e4
Copy link
Author

3e4 commented Mar 31, 2014

Thank you for your patient replies.

Based on what you write I will switch my current project to PyQT4/python2.7.

@davidhalter
Copy link
Owner

I wouldn't switch back to Python2 just because my autocompletion doesn't work with Python 3. I think it's wise of you to choose Python 3.

Things you could try to get it working: Do a :python import sys; print(sys.version_info) and then install PyQT4 for that explicit Python version. I would actually also be interested what the above version_info returns if you're using :let g:jedi#force_py_version = 3

@3e4
Copy link
Author

3e4 commented Mar 31, 2014

Ok, further debug:

After activating my virtualenv (jeditest) in cmd:

echo %PATH%
C:\Users\******\Documents\jeditest\Scripts;C:\Python33\Lib\site-packages\PyQt5
;C:\Program Files\ImageMagick-6.8.8-Q16;C:\Program .....

dir c:\Users\******\Documents\jeditest\Scripts
 activate
 activate.bat
 activate.ps1
 activate_this.py
 deactivate.bat
 easy_install-3.3.exe
 easy_install.exe
 pip.exe
 pip3.3.exe
 pip3.exe
 python.exe
 pythonw.exe

then starting vim with "gvim", and inside vim

:echo g:jedi#force_py_version
2
:python import sys; print(sys.version_info)
2.7.3 final
:call jedi#force_py_version_switch()
:echo g:jedi#force_py_version
3
:python import sys; print(sys.version_info)
2.7.3 final
:echo $PATH
[same as above from CMD]

Hmm.. we might be up to something. Does not switch interpreter. Note: I get the same result when starting "vim" (not "gvim") in cmd.

@davidhalter
Copy link
Owner

It does. You need to do :python3. (jedi-vim uses a variable for that internally)

@3e4
Copy link
Author

3e4 commented Apr 1, 2014

Ok, when running :python3 I get 3.3.5 final.

Even if I deactivate the virtualenv.

I might have found the problem. Running

:python3 import sys; print(sys.path)
['C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\Users\\********\\Documents\\jeditest', 'C:\\Program Files (x86)\\Vim\\Vim74', '_vim_path_']

So how to get the extra python33 stuff out or move to after my virtualenv?

@davidhalter
Copy link
Owner

That's interesting. I don't know.

@3e4
Copy link
Author

3e4 commented Apr 1, 2014

Further to my answer ~20 minutes ago:

Python 3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 10:37:12) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', 'c:\\users\\*******\\documents\\jeditest33\\src\\jedi', 'C:\\Windows\\syst
em32\\python33.zip', 'C:\\Users\\*******\\Documents\\jeditest33\\DLLs', 'C:\\Us
ers\\******\\Documents\\jeditest33\\lib', 'C:\\Users\\******\\Documents\\jed
itest33\\Scripts', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\Users\\*****\\Documents\\jeditest33', 'C:\\Users\\*****\\Documents\\jeditest33\\lib\\site-packages']

This is not the same that vim's :python3 shows. I'm using here jeditest33 virtualenv, but I get the same result for jeditest.

@3e4
Copy link
Author

3e4 commented Apr 1, 2014

Sorry for dumping very noisy messages.

I now tried again the whole thing without virtualenv.

C:\Users\*****\Documents>py -3
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar  9 2014, 10:37:12) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', 'C:\\Python33\\lib\\site-packages\\distribute-0.7.3-py3.3.egg', 'C:\\Python33\\lib\\site-packages\\setuptools-3.3-py3.3.egg', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\DLLs', C:\\Python33\\lib', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages']

and in gvim:

['c:\\Users\\*****\\*****\\bundle\\jedi-vim', 'C:\\Python33\\lib\\site-packages\\distribute-0.7.3-py3.3.egg', 'C:\\Python33\\lib\\site-packages\\setuptools-3.3-py3.3.egg', 'C:\\Windows\\system32\\python33.zip', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\Users\\*****\\Documents', 'C:\\Program Files (x86)\\Vim\\Vim74', 'C:\\Python33', 'C:\\Python33\\lib\\site-packages', '_vim_path_']

Now in gvim, with jedi#force_py_version = 3 I get completion for PyQt5. (However Leader+d not working: "Builtin modules cannot be displayed". Maybe because only in binary?)

Edit: Yes, only .pyd and .dll files.

@davidhalter
Copy link
Owner

Sorry for dumping very noisy messages.

Don't excuse for all the copy pasting, it's what we need to debug this.

However Leader+d not working: "Builtin modules cannot be displayed". Maybe because only in binary?

Yeah, I should still improve that message.

The big question is basically how why gvim and vim are different? did you install two different versions of VIM? I don't really know any windows related VIM things anyway.

@3e4
Copy link
Author

3e4 commented Apr 1, 2014

I don't see any difference between vim and gvim. Maybe that was not clear from my comments.

Where I do see a difference is between py -3 run from within cmd.exe (I posted the outputabove), and between :python3 run from within gvim (started from the same cmd.exe session).

About docstring in pyqt (Leader-d). Seems the source itself is not python. So I guess I have to stick to the reference guide on the internet.

@davidhalter
Copy link
Owner

Is there still an issue? I really lost the context here :-)

@3e4
Copy link
Author

3e4 commented Apr 1, 2014

There is still an issue, but to my understanding not with jedi or jedi-vim.

Jedi-vim did not behave as expected when using a virtualenv, because the path is set wrong (vim problem?).

Since the reason I started using virtualenv in the first place was because I worried that jed-vim gets confused with python2/3, but actually g:jedi#force_py_version works as expected, there is no more problem with jedi-vim. (^^) I stop using virtualenv and everything is fine.

@davidhalter
Copy link
Owner

Haha :-) I'm closing this one. True virtualenv support might come with davidhalter/jedi#385.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants