Registered Member
|
Hi there!
Will it be too hard to implement virtualenv loading in KDevelop python projects? I know that one could use the PYTHONPATH envvar to override it but with multiple projects in multiple virtualenvs it gets inconvenient to do so. Furthermore, setting PYTHONPATH doesn't use the interpreter from the virtualenv and I sometimes have to deploy on systems where the default interpreter is old (CentOS 6 uses 2.6 as default), but the modules require newer. Thanks! |
Registered Member
|
Even PYTHONPATH is not working, what version were you using?
https://bugs.kde.org/show_bug.cgi?id=322477 |
Global Moderator
|
The bug is just for the env vars set inside kdevelop. If you start the kdevelop process with PYTHONPATH in its env, it will resepct that, at least for finding includes.
I am not sure what you would expect from virtualenv support. What would it be supposed to do, i.e. what features could there be which would make your life easier? Greetings, Sven
I'm working on the KDevelop IDE.
|
Registered Member
|
I am trying out kdevelop to see if it can replease eclipse/pydev for me. This is indeed one of the features that I am missing or at least that is not clear to me. Integrating virtualenv would enable me to start and debug applications in their own controlled environment that I build for this application. If each application can have their own separate virtual environment I can develop these projects in parallel in the IDE (like I do in pydev) without problems. I am actually surprised that KDevelop does not use virtual env as it is the preferred way to deploy python projects.
|
Global Moderator
|
I do not use virtualenv, Python code I write is almost always for personal or scientific use and is not deployed. Again, how exactly would integration have to look like to make it useful for you?
I'm working on the KDevelop IDE.
|
Registered Member
|
I have just started using Kdevelop. It is very good and kdev-python is excellent apart from the lack of virtualenv support.
There are two things needed. The most important is that auto-completion should use a particular virtualenv on a per project basis. This is particularly important if you are using a library that is either only installed in a virtual env, or you have two projects with different versions of a library that has been rearranged so import paths differ between the two versions. The other thing required is running projects/files within the virtualenv. This is possible by configuring a script application launcher. it would be nice to be able to specify a virtualenv and have the python executable in that as the project default and the libraries in it included for autocompletion in one step, but as it is once per project configuration it is not important. It would also be easier if there was a file picker for the interpreter path as there is for the script file path. |
Global Moderator
|
Hi,
Okay. Right now I think you can work around that by going to the project configuration, and under "Includes/Imports" add your library paths. Unfortunately I'm not sure this works in 4.7, but in 5.0 it will work Another workaround you can do and which certainly works is starting KDevelop with PYTHONPATH=$PYTHONPATH:/path/to/libs kdevelop, but that only works on a per-session basis of course. I guess it would make sense to have a config option for a default python interpreter on a per-project basis. If we had that, could we get the include paths from what this interpreter thinks "sys.path" contains? Having a file picker for the interpreter in Run is already on my todo list, because on Windows it's sort of needed anyways. Greetings, Sven
I'm working on the KDevelop IDE.
|
Registered Member
|
I checked sys.path in a few virtualenvs and it seems to contain exactly the paths you need. Apart from the paths local to the virtualenv it includes user local and system wide paths when the virtualenv is configured to use them and excludes them when it is configured not to allow them.
Does not work in 4.7 Looking forward to 5.0 , neither does setting PYTHONPATH, nor starting from the command line with the virtual env activated (which works for vim with Jedi autocompletion). Another problem caused by not having the right paths for the virtualenv is that the problems tool view becomes very noisy with a lot of "Module not found" and "undefined variable" errors. Despite the rough edges I really like Kdevelop for Python and it is my favourite Python IDE: it has the features I need, but it feels responsive, the UI is excellent and autocompletion works very well most of the time. Thanks for all the work you have put into it. |
Global Moderator
|
I will see that we can get a configurable python interpreter for a project.
As a last resort re. "module not found", you can open the path containing those modules as a project. Remember that you have to press F5 in the affected files so they are actually re-analyzed. Good to hear that some other features work well for you, though.
I'm working on the KDevelop IDE.
|
Registered Member
|
I have come across another oddity: all other imports from standard libraries are fine, but
gives this in the problems tool view:
|
Global Moderator
|
I *guess* this is https://bugs.kde.org/show_bug.cgi?id=359907 (or something similar).
I'm working on the KDevelop IDE.
|
Registered Member
|
Yes, that was it.
I also found that installing things user local was a good workaround. It caused problems for one module, but that is a virtualenv issue. |
Global Moderator
|
I implemented something like that now, you can configure a per-project Python interpreter in the project settings. Search paths will be retrieved from that. The feature will be available starting with version 5.1.
https://quickgit.kde.org/?p=kdev-python ... 8a465f73c2
I'm working on the KDevelop IDE.
|
Registered Member
|
Great to see this feature coming to 5.1.
For now, I use the following script quite successfully. I use virtualenvwrapper and name my kdevelop sessions similarly to venv environment. Then I use the following script to launch kdevelop:
|
Registered Member
|
It's greyed out in the menu. I mean Project > Open configuration. It's inactive no matter what I do. Any suggestions? Kdevelop 5.5.0 Update: was able to get into project settings again after re-enabling Projects tool view. But venv imports are still not recognized yet. |
Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]