yarolig / pyqtc

Python browsing and code completion for Qt Creator
GNU General Public License v3.0
1 stars 0 forks source link

pyqtc is not working #1

Open tomi707 opened 7 years ago

tomi707 commented 7 years ago

Plugin is installed with:

Plugin is visible in QtCreator and python code is highlighted. But code completion and navigation is not working. Only whole python file is displayed in console where QtCreator is starded.

yarolig commented 7 years ago

Thank you for trying pyqtc!

I have some ideas what may be broken. And now I want to fix EVERYTHING!

Guess 1

File is opened using Python plugin included in QtCreator.

You can disable it in Help-> About Plugins -> Other Languages -> PythonEditor. OR you can open python files with Pyqtc editor explicitly by right-clicking on a file in Projects View and selecting Open With -> Python Editor (pyqtc)

I should add it to README or do something with stock PythonEditor.

Guess 2

Some python modules are missing.

Open QtCreator again, do not open any files, read the console. I expect following log if python-protobuf absent:

$ /opt/qtcreator/4.4/bin/qtcreator
Starting worker "python" ("/opt/qtcreator/4.4/share/qtcreator/pyqtc/worker.zip", "/tmp/pyqtc_509748353")
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/opt/qtcreator/4.4/share/qtcreator/pyqtc/worker.zip/__main__.py", line 18, in <module>
  File "/opt/qtcreator/4.4/share/qtcreator/pyqtc/worker.zip/rpc_pb2.py", line 6, in <module>
ImportError: No module named google.protobuf.internal
pyqtc Plugin::initialize

Guess 3

Project is too large and it takes some time to be indexed.

Run top command. If python process is consuming 100% CPU. Ctrl+Space and F2 will not work untill it ended.

It happens when project contain many *.py files or when project directory contains big file tree (file names don't matter). Indexing speed is 4 python files per second on my computer.

tomi707 commented 7 years ago

1) I have disable PythonEditor. Open With -> Python Editor (pyqtc) helps with colors scheme 2) QtCreator needs libprotobuf10 but plugin needs libprotobuf7. I had some linking errors but solved it and I compiled plugin. I remember "ImportError: No module named google.protobuf" when I start qtcreator. So, seems plugin cannot find libprotobuf7 ? 3) Yes, when I open python file I see about 90-100% for python process. But open file is not too big.

yarolig commented 7 years ago

Seems plugin can't find python protobuf library.

There is different protobuf libraries for C++ and for Python. C++ library is file libprotobuf.so somewhere in /usr/lib. Python library is set of *.py files somewhere in /usr/lib/python2.7/dist-packages/google/protobuf.

I recommend to install python protobuf library with your package manager. Debian or Ubuntu package called python-protobuf. If there is no such packages try pip install protobuf

Which linux distributive do you use? Or is it Mac OS X?

tomi707 commented 7 years ago

I use ubuntu 17.04. Qt 5.7.1 I installed python-protobuf and now I don't see error "ImportError: No module named google.protobuf" I open pyqtc/tools/sphinx2qhcp.py and when I use ctrl+space the python process starts to use about 100% CPU. File content is displayed in console where I started qtcreator with something like this on the beginning: id: 1 completion_request { context { ....

Maybe it is important to fix it: pyqtc Plugin::initialize qrc:/timeline/MainView.qml:27:1: module "QtQuick.Controls" is not installed qrc:/timeline/MainView.qml:28:1: module "QtQuick.Controls.Styles" is not installed qrc:/timeline/MainView.qml:27:1: module "QtQuick.Controls" is not installed qrc:/timeline/MainView.qml:28:1: module "QtQuick.Controls.Styles" is not installed QObject::connect: Cannot connect (null)::updateCursorPosition() to QmlProfiler::Internal::QmlProfilerTraceView::updateCursorPosition() qrc:/qmlprofiler/QmlProfilerFlameGraphView.qml:27:1: module "QtQuick.Controls" is not installed QObject::connect: Cannot connect (null)::typeSelected(int) to QmlProfiler::Internal::FlameGraphView::typeSelected(int) QObject::connect: Cannot connect (null)::gotoSourceLocation(QString,int,int) to QmlProfiler::Internal::FlameGraphView::gotoSourceLocation(QString,int,int) addOverrideAction /: Action / is already registered for context Global Context. addOverrideAction /: Action / is already registered for context Global Context. Worker connected to "/tmp/pyqtc_-1689767375" addOverrideAction /: Action / is already registered for context Global Context. addOverrideAction /: Action / is already registered for context Global Context.

I installed qml-module-qtquick-controls and I don' t see warning with QtQuick.Controls, but still 100% python process..