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

Jupyter Qtconsole can't find PyQt5 #408

Closed
GabrieleZucca opened this issue Feb 6, 2020 · 6 comments · Fixed by #409
Closed

Jupyter Qtconsole can't find PyQt5 #408

GabrieleZucca opened this issue Feb 6, 2020 · 6 comments · Fixed by #409
Milestone

Comments

@GabrieleZucca
Copy link

GabrieleZucca commented Feb 6, 2020

When launching jupyter qtconsole:

$ jupyter qtconsole
Traceback (most recent call last):
  File "/home/gabriele/.local/bin/jupyter-qtconsole", line 6, in <module>
    from qtconsole.qtconsoleapp import main
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/qtconsoleapp.py", line 60, in <module>
    from qtconsole.qt import QtCore, QtGui
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/qt.py", line 23, in <module>
    QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/qt_loaders.py", line 387, in load_qt
    api_options))
ImportError: 
    Could not load requested Qt binding. Please ensure that
    PyQt4 >= 4.7, PyQt5, PySide >= 1.0.3 or PySide2 is available,
    and only one is imported per session.

    Currently-imported Qt library:   None
    PyQt4 installed:                 False
    PyQt5 installed:                 False
    PySide >= 1.0.3 installed:       False
    PySide2 installed:               False
    Tried to load:                   ['pyqt5', 'pyside2', 'pyside', 'pyqt']

My system is Xubuntu 19.10 64 bit. Further info:

$ python3 --version
Python 3.7.5

$ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

$ pip3 show jupyter
Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.
Home-page: http://jupyter.org
Author: Jupyter Development Team
Author-email: jupyter@googlegroups.org
License: BSD
Location: /home/gabriele/.local/lib/python3.7/site-packages
Requires: ipykernel, jupyter-console, qtconsole, nbconvert, ipywidgets, notebook
Required-by: 

$ pip3 show pyqt5
Name: PyQt5
Version: 5.12.3
Summary: None
Home-page: None
Author: None
Author-email: None
License: None
Location: /usr/lib/python3/dist-packages
Requires: 
Required-by: 

Jupyter has been installed with pip3 with the --user option, while PyQt5 has been installed with apt (package: python3-pyqt5).

@wmvanvliet
Copy link
Contributor

What happens if you open a regular python REPL and do: from PyQt5 import QtGui?

@GabrieleZucca
Copy link
Author

It loads without any error it seems.

PS: Inoticed that on my other PC jupyter qtconsole works. The main difference is that on that other PC jupyter has been installed system-wide with sudo pip3 install jupyter instead of pip3 install --user jupyter. The OS is the same.

@wmvanvliet
Copy link
Contributor

Can you try with the latest master? I think we recently changed our QT detection code for the better.

@GabrieleZucca
Copy link
Author

GabrieleZucca commented Feb 8, 2020

I tried reinstalling from GitHub with pip3 install --user git+https://github.com/jupyter/qtconsole and now I get a different error:

Traceback (most recent call last):
  File "/home/gabriele/.local/bin/jupyter-qtconsole", line 6, in <module>
    from qtconsole.qtconsoleapp import main
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/qtconsoleapp.py", line 65, in <module>
    from qtconsole.rich_jupyter_widget import RichJupyterWidget
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/rich_jupyter_widget.py", line 13, in <module>
    from qtconsole.svg import save_svg, svg_to_clipboard, svg_to_image
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/svg.py", line 5, in <module>
    from qtpy import QtCore, QtGui, QtSvg, QtWidgets
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtpy/QtSvg.py", line 14, in <module>
    from PyQt5.QtSvg import *
ModuleNotFoundError: No module named 'PyQt5.QtSvg'

I cannot load it in a normal python3 repl either.

@GabrieleZucca
Copy link
Author

GabrieleZucca commented Feb 8, 2020

After the last post I installed the python3-pyqt5.qtsvg package with apt and now the qtconsole seems to work, even if the terminal shows some errors:

Traceback (most recent call last):
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
    handler(msg)
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/frontend_widget.py", line 504, in _handle_inspect_reply
    self._call_tip_widget.show_inspect_data(content)
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/call_tip_widget.py", line 134, in show_inspect_data
    return self.show_tip(self._format_tooltip(text))
  File "/home/gabriele/.local/lib/python3.7/site-packages/qtconsole/call_tip_widget.py", line 158, in show_tip
    screen_rect = QtWidgets.QApp.desktop().screenGeometry(text_edit)
AttributeError: module 'qtpy.QtWidgets' has no attribute 'QApp'

EDIT: Replacing the 2 occurrencies of QApp with qApp in qtconsole/call_tip_widget.py solves the problem :)

@wmvanvliet
Copy link
Contributor

Great that you solved it. Seems like a compatibility PR is called for, based on your observations.

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

Successfully merging a pull request may close this issue.

3 participants