Summary: | Python: autocompletion not available for library installed in virtualenv | ||
---|---|---|---|
Product: | [Developer tools] kdev-python | Reporter: | Gregor Mi <codestruct> |
Component: | general | Assignee: | Sven Brauch <mail> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | mail, nalvarez |
Priority: | NOR | ||
Version: | 5.0.0 | ||
Target Milestone: | --- | ||
Platform: | Appimage | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kdev-python/82729e275d176a81101da98f9af4fd8a465f73c2 | Version Fixed In: |
Description
Gregor Mi
2016-09-17 19:09:35 UTC
Add the path in Configure Project -> Include paths. I eventally want to support a configurable python interpreter per project to retrieve paths from, that's a long-standing feature request ... I created a new Python project, added my source file and put /home/gregor/.virtualenvs/arcade/lib/python3.5/site-packages (which contains an arcade folder with the py files) into Open Configuration... > Include/Imports. Now, `import arcade` is not underlined anymore but I still cannot navigate to the source or get auto-completion for arcade types. Hmm, is that package written in Python? Does pressing F5 change anything? Maybe the project wasn't reparsed. I pressed F5 and it did change nothing. The .../site-packages/arcade directory looks like this: total 180 -rw-r--r-- 1 2165 Sep 17 20:46 application.py -rw-r--r-- 1 373 Sep 17 20:46 arcade_types.py drwxr-xr-x 3 4096 Sep 17 20:51 color -rw-r--r-- 1 57629 Sep 17 20:46 draw_commands.py -rw-r--r-- 1 4244 Sep 17 20:46 geometry.py -rw-r--r-- 1 716 Sep 17 20:46 __init__.py drwxr-xr-x 3 4096 Sep 17 20:51 key -rw-r--r-- 1 11703 Sep 17 20:46 physics_engine_2d.py -rw-r--r-- 1 8473 Sep 17 20:46 physics_engines.py drwxr-xr-x 2 4096 Sep 17 20:51 __pycache__ -rw-r--r-- 1 9409 Sep 17 20:46 shape_objects.py -rw-r--r-- 1 1931 Sep 17 20:46 sound.py -rw-r--r-- 1 26546 Sep 17 20:46 sprite.py -rw-r--r-- 1 332 Sep 17 20:46 test.py -rw-r--r-- 1 332 Sep 17 20:46 types.py -rw-r--r-- 1 94 Sep 17 20:46 version.py -rw-r--r-- 1 6819 Sep 17 20:46 window_commands.py So I assume it is written in Python (this is the website: http://pythonhosted.org/arcade/index.html) Hm, in the sample code I can't even find "import arcade" ... Ah, sorry, here is the example code that I experimented with: http://pythonhosted.org/arcade/examples/sprite_move_walls.html (the first non-comment statement is import arcade). I installed arcade as described here: http://pythonhosted.org/arcade/installation_linux.html #virtualenv ~/.virtualenvs/arcade -p python3 #instead of the above line, for openSUSE 42.1 I installed the opt python35 package because python >= 3.5 is required: https://software.opensuse.org/package/opt-python35 virtualenv ~/.virtualenvs/arcade -p /opt/python/bin/python3.5 source ~/.virtualenvs/arcade/bin/activate pip install arcade # takes a while Ok, works perfectly fine here with arcade installed system-wide, so the problem is with paths somehow. Can you export QT_LOGGING_RULES=kdev.python.duchain.debug=true and watch for the "search paths" line which prints all the search paths? ``` ====> DUCHAIN ====> rebuilding duchain for "/home/gregor/dev/src/tp64/unsorted/kdevelop/pyproj1/arcade1.py" (was built before) kdev.python.duchain: --- Search paths from cache: (QUrl("file:///usr/lib/python34.zip"), QUrl("file:///usr/lib64/python3.4"), QUrl("file:///usr/lib64/python3.4/plat-linux"), QUrl("file:///usr/lib64/python3.4/lib-dynload"), QUrl("file:///home/gregor/.local/lib/python3.4/site-packages"), QUrl("file:///usr/lib64/python3.4/site-packages"), QUrl("file:///usr/lib64/python3.4/_import_failed"), QUrl("file:///usr/lib/python3.4/site-packages")) kdev.python.duchain: Found module path [path/path in file]: QPair(QUrl("file:///home/gregor/.virtualenvs/arcade/lib/python3.5/site-packages/arcade/__init__.py"),()) kdev.python.duchain: Declaration identifier: "arcade" kdev.python.duchain: creating declaration tree for ("arcade") kdev.python.duchain: really encountered: 0x7fdfb81da690 ; scheduled: () kdev.python.duchain: "mixed arcade" kdev.python.duchain: scheduled: () kdev.python.duchain: creating context for "arcade" kdev.python.duchain: adding imported context to inner declaration kdev.python.duchain: closing context kdev.python.duchain: creating declaration tree for ("arcade", "application") kdev.python.duchain: Found existing import statement while creating declaration for "arcade.application" kdev.python.duchain: remaining identifiers: ("application") kdev.python.duchain: really encountered: 0x7fdfb80b4f60 ; scheduled: (0x7fdfb80b4f60, 0x7fdfb80eccc0, 0x7fdfb89074f0, 0x7fdfb80fcb90, 0x7fdfb80fb1d0, 0x7fdfb8135ac0, 0x7fdfb8130770, 0x7fdfb82fd9d0, 0x7fdfb809b790, 0x7fdfb81044d0, 0x7fdfb8138b10, 0x7fdfb8138990, 0x7fdfb80ecc40) kdev.python.duchain: "mixed application" kdev.python.duchain: scheduled: (0x7fdfb80eccc0, 0x7fdfb89074f0, 0x7fdfb80fcb90, 0x7fdfb80fb1d0, 0x7fdfb8135ac0, 0x7fdfb8130770, 0x7fdfb82fd9d0, 0x7fdfb809b790, 0x7fdfb81044d0, 0x7fdfb8138b10, 0x7fdfb8138990, 0x7fdfb80ecc40) ``` So arcade seems to be found. Maybe it is because kdevelop has only python 3.4 packages in the search path and not any of 3.5? That shouldn't be a problem ... i'll have to try that out. Maybe there is a problem with the scheduling for those extra paths, although I have no idea why that would be. For comparison I tried again with another library PyQt5. There I have code like this: ``` import sys from PyQt5.QtWidgets import QWidget, QApplication from PyQt5.QtGui import QPainter, QColor, QPen from PyQt5.QtCore import Qt class Example(QWidget): def __init__(self): super().__init__() self.initUI() ... ``` The when I hover over the base class of Example (QWidget) then the documentation is properly shown in the tooltip (and the corresponding QtHelp for C++ can be opened which is cool). Navigation to the corresponding python file is not possible with Ctrl+Click, though. Git commit 82729e275d176a81101da98f9af4fd8a465f73c2 by Sven Brauch. Committed on 23/10/2016 at 11:25. Pushed by brauch into branch 'master'. Allow configuring a per-project Python interpreter for search paths. This introduces rudimentary support for virtualenv, since you can now set the virtualenv's "python" as the project's interpreter. M +2 -1 CMakeLists.txt M +1 -1 codecompletion/context.cpp M +2 -2 duchain/contextbuilder.cpp M +29 -13 duchain/helpers.cpp M +4 -4 duchain/helpers.h A +52 -0 projectconfig/projectconfig.ui A +43 -0 projectconfig/projectconfigpage.cpp [License: UNKNOWN] * A +45 -0 projectconfig/projectconfigpage.h [License: GPL (v2+)] M +15 -1 pythonlanguagesupport.cpp M +3 -0 pythonlanguagesupport.h M +1 -1 pythonparsejob.h The files marked with a * at the end have a non valid license. Please read: http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are listed at that page. http://commits.kde.org/kdev-python/82729e275d176a81101da98f9af4fd8a465f73c2 |