Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi  - Page 1
Forum section: electronics / general

author: rx8pilot
author_rank: Super Contributor
timestamp: January 22, 2020, 03:15:52 am
content: I have been developing a Qt5 based application that so far runs on Windows / MacOS / Linux Mint but I am now stuck trying to get PyQt5 module installed on a FriendlyELEC NanoPi Fire3 (Rasberry Pi clone). My Linux skills are modest - able to fluidly move around, deal with permissions, users, samba, editing text files, etc, etc. Far from expert though. Setting this up in Mint was effortless.After a crash and burn on Stack Overflow.....I thought this group may have some more constructive insight.The Linux distro id lubuntu as distributed from Friendly. Python 3.5.2.I have installed Qt5, and the module loads in Python, but none of the PyQt5 modules are availableCode:apt-get install python3-qt5When trying to install PyQt5 wheel, it fails. Perhaps I need to manually install it somehow? I downloaded the PyQt5 source as a TAR, but not sure how to build it into anything useful.Code:pip3 install PyQt5results:Code:root@FriendlyELEC:/etc/samba# pip3 install PyQt5Collecting PyQt5Downloading PyQt5-5.14.1.tar.gz (3.2 MB)|################################| 3.2 MB 29 kB/sInstalling build dependencies ... doneGetting requirements to build wheel ... donePreparing wheel metadata ... errorERROR: Command errored out with exit status 1:command: /usr/bin/python3 /usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp6mm9iz7icwd: /tmp/pip-install-q4uoq45z/PyQt5Complete output (35 lines):Querying qmake about your Qt installation.../usr/bin/qmake -queryTraceback (most recent call last):File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 103, in prepare_metadata_for_build_wheelhook = backend.prepare_metadata_for_build_wheelAttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'During handling of the above exception, another exception occurred:Traceback (most recent call last):File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 257, in <module>main()File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 240, in mainjson_out['return_val'] = hook(**hook_input['kwargs'])File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 108, in prepare_metadata_for_build_wheelconfig_settings)File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 136, in _get_wheel_metadata_from_wheelwhl_basename = backend.build_wheel(metadata_directory, config_settings)File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/api.py", line 51, in build_wheelproject = AbstractProject.bootstrap('pep517')File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/abstract_project.py", line 82, in bootstrapproject.setup(pyproject, tool, tool_description)File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/project.py", line 387, in setupself.apply_user_defaults(tool)File "project.py", line 62, in apply_user_defaultssuper().apply_user_defaults(tool)File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaultssuper().apply_user_defaults(tool)File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/project.py", line 202, in apply_user_defaultsself.builder.apply_user_defaults(tool)File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/pyqtbuild/builder.py", line 76, in apply_user_defaultsself._get_qt_configuration()File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/pyqtbuild/builder.py", line 463, in _get_qt_configuration"v{0}".format(self.qt_version_str))sipbuild.exceptions.UserException----------------------------------------ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp6mm9iz7i Check the logs for full command output.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 22, 2020, 05:36:06 am
content: In current Ubuntu variants, the Python3 Qt5 bindings are in a package namedpython3-pyqt5(but you'll also want to install python3-pyqt5.qtsvg, python3-pyqt5.qtwebkit, and python3-pyqt5.qtopengl). So, try runningsudo apt install python3-pyqt5 python3-pyqt5.{qtsvg,qtwebkit,qtopengl}instead. (Note the extrapyinpython3-pyqt5.)Let me know if this does not fix the issue for you. (If not, please include the output ofcat /etc/issue /etc/debian_version, i.e. the version of the Linux distribution you are using.)Edit: I see FriendlyARM provide a Xenial (Ubuntu 16.04) -based image for the NanoPi Fire3. I am not absolutely sure about this, as I'm on 18.04, and the necessary bindings (/usr/lib/python3/dist-packages/PyQt5/, including binary libraries, and alibpyqt5.soplugin for the Qt designer) are provided bypython3-pyqt5orpython3-pyqt5.*on 18.04.

author: rx8pilot
author_rank: Super Contributor
timestamp: January 22, 2020, 06:00:32 am
content: Quote from: Nominal Animal on January 22, 2020, 05:36:06 amWOW!!!!This worked immediately without any issue.I just ran the test code and it runs perfect.I am curious.....where should I have been looking for that information if you were not available to deliver the answer on a silver platter? I spent most of yesterday looking for a way to get PyQt5 installed on this Pi clone. Is this as obscure as I think it is, or am I just not looking in the right places?Anyway....I really appreciate the assist. Very helpful.

author: Nominal Animal
author_rank: Super Contributor
timestamp: January 22, 2020, 06:55:14 am
content: Quote from: rx8pilot on January 22, 2020, 06:00:32 amExcellent!Quote from: rx8pilot on January 22, 2020, 06:00:32 amI would recommend always doing an apt list first:apt list '*python3*qt5*'ordpkg-query -l '*py*qt5*'Then, when you see interestingly-named packages, check them viaapt show python3-pyqt5Personally, I like the Synaptic GUI (in X) package manager interface better. Justsudo apt install synaptic, then run it (Menu > Administration > Synaptic Package Manager). Doing a package search for "python3" and "qt5" for names and descriptions pops it up immediately; that's what I normally do, and how I verified it.Of course, this has the downside that you must be running on the target system already, to find stuff out. Yet, it is much, much faster than doing a web search.Quote from: rx8pilot on January 22, 2020, 06:00:32 amUsing Synaptic or Aptitude (apt package manager user interfaces), makes things much, much easier; give them a go.Maintaining systems at the package level using command-lineapttools only is pretty obscure and lots of work; that's whySynapticwas developed in the first place. If you don't have X (and are, say, SSH'ing to it), then useAptitude, a terminal package manager (using ncurses); it provides the same features as Synaptic.(Installing and updating packages is trivial on the command line, but finding outexactly what to installis much easier using the nice search interfaces in the graphical user interface. It is that search-and-find-out step, that these GUI package managers help with; not the trivial tasks.)In general terms, I have found that Windows power users have the hardest time to adapt to the idea ofalways first do a search on the package managerinstead of going on the web and downloading something to install; those completely new to computers find it much easier a maintenance approach.I do not say this to disparage anyone, but to highlight the fact that this (package management) is one of the key "philosophical" differences, a major paradigm shift, between Windows and Linux. So, if you have lots of Windows maintenance/install experience, be aware of this key difference and remind yourself to do a package manager search (over names and descriptions)before a web search, and it will become much easier. (The underlying reason is that while the package namesseemuniversal, they are very much up to the distribution managers, and can in fact vary between Linux distributions. However, if you always use the distros own package manager (via a nice GUI, preferably), you'll always do it the way the distro managers intended you; and the way you search for and find the appropriate packages to install is the same -- even if the names might vary.)The transition period can be jarring and quite frustrating, however; but it will pass, if you persist.

author: djnz
author_rank: Regular Contributor
timestamp: January 30, 2020, 10:31:18 am
content: I'd also suggestCode:sudo apt install build-essentialI am going to deviate from the above recommendation of using synaptic / the system package manager for everything. I do use the system packages for some things, but in general, have found that for python, using project-specific virtual environments works better. It allows you to manage dependency versions well, and it also makes it easier to deploy the final code to other machines.So something like:Code:cd project_dir# setup a virtual environment in the venv directorypython3 -m venv venv# use the virtual environmentsource venv/bin/activateand then the actual stuff. You can verify that you are using the virtual environment versions by something likeCode:type pythontype pipand it should confirm that the ones in the virtual environment are being used.

author: ebastler
author_rank: Super Contributor
timestamp: February 02, 2020, 04:51:08 pm
content: Quote from: rx8pilot on January 22, 2020, 06:00:32 amNot sure what you were looking for? When I Google "python qt5 ubuntu", the first two hits arehttps://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ffandhttps://stackoverflow.com/questions/36757752/how-to-install-pyqt5-in-python-3-ubuntu-14-04.Both explain that you want toCode:sudo apt-get install python3-pyqt5Neither mentions the qtwebkit etc. packages which Nominal Animal clued us in on, but these probably weren't your primary stumbling block?

author: rx8pilot
author_rank: Super Contributor
timestamp: February 03, 2020, 12:58:34 am
content: Quote from: ebastler on February 02, 2020, 04:51:08 pmThe answer is always easier to find when you Google the right answerI have already let many of the battle details fall out of my brain, but what I remember is that first I was trying to get it installed an a headless distro that was provided by Friendly. Not sure what the details are, but I was searching and experimenting with that distro and everything I could find at the time simply suggested:Code:sudo apt-get install PyQt-5which never worked. I never recall seeing anything suggesting:Code:sudo apt-get install Python3-Qt5and definitely did not know of any dependencies like what @Nominal Animal suggested.Code:apt install python3-pyqt5 python3-pyqt5.{qtsvg,qtwebkit,qtopengl}Since Linux is still quite new to me....troubleshooting installation issues is not yet part of my skillset. I found various bits and pieces of advice from a number of sources - all of which was leading me down the wrong path. Getting further from the solution. One of my friends that has developed on these FriendlyElec Pi's told me he just compiled from source Qt, all the dependencies, etc, etc.....I was not ready for yet another learning curve so I did not try that.One of the turning points, was when I realized that I don't believe PyQt5 works outside of a GUI. That is when I switched to lubuntu where it does work just fine.Either way - I had no idea what to look for. After this, I have spent a lot more time studying Linux and starting to feel more comfortable dealing with troubleshooting. Still a beginner (perhaps now I am an advanced beginner).