[Ubuntu] PyQt5

Chris Angelico rosuav at gmail.com
Sun Nov 8 11:22:07 EST 2015


On Mon, Nov 9, 2015 at 3:03 AM, Andrew Diamond <adiamond1978 at gmail.com> wrote:
> On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond wrote:
>> Hi!
>>
>> I'm fairly new to Python, and installed pyqt5 and began working through the examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I click one of the buttons or menus in the example apps I run that is supposed to quit the application, it locks up.  This happens with all the examples I installed that handle code to quit the app.
>>
>> Running Ubuntu 15.10, and installed pyqt5 via:
>>
>> sudo apt-get install python3-pyqt5
>> sudo apt-get install qtcreator
>>
>> Thank you in advance for any assistance!
>
> I just read somewhere that the issue could be because I was trying to run these examples from within Idle.  However, when I try to run them from the terminal, I run into another snag:
>
> andrew at andrew-Satellite-P755:~/Programming/Python$ python tut8.py
> Traceback (most recent call last):
>   File "tut8.py", line 16, in <module>
>     from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
> ImportError: No module named PyQt5.QtWidgets
>
> ...a path issue?

If you installed "python3-pyqt5", you probably want to run "python3
tut8.py". There are potentially two completely separate Python
interpreters installed - version 2.7, and the latest available version
3.x (probably 3.4 or 3.5). You've installed a package for Python 3,
but haven't installed the corresponding Python 2 package, so it won't
run under the Python 2 interpreter. Compare these:

$ python --version
$ python3 --version

I suspect that "python3 tut8.py" should work. If it doesn't, post some
more info about your Idle installation; it might give a hint as to
what's going on.

ChrisA



More information about the Python-list mailing list