Author Topic: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi  (Read 5947 times)

0 Members and 1 Guest are viewing this topic.

Offline rx8pilotTopic starter

  • Super Contributor
  • ***
  • Posts: 3644
  • Country: us
  • If you want more money, be more valuable.
Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« on: January 22, 2020, 03:15:52 am »
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 available

Code: [Select]
apt-get install python3-qt5
When 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: [Select]
pip3 install PyQt5
results:
Code: [Select]
root@FriendlyELEC:/etc/samba# pip3 install PyQt5
Collecting PyQt5
  Downloading PyQt5-5.14.1.tar.gz (3.2 MB)
     |################################| 3.2 MB 29 kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: 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/tmp6mm9iz7i
         cwd: /tmp/pip-install-q4uoq45z/PyQt5
    Complete output (35 lines):
    Querying qmake about your Qt installation...
    /usr/bin/qmake -query
    Traceback (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_wheel
        hook = backend.prepare_metadata_for_build_wheel
    AttributeError: 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 main
        json_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_wheel
        config_settings)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pep517/_in_process.py", line 136, in _get_wheel_metadata_from_wheel
        whl_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_wheel
        project = AbstractProject.bootstrap('pep517')
      File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
        project.setup(pyproject, tool, tool_description)
      File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/project.py", line 387, in setup
        self.apply_user_defaults(tool)
      File "project.py", line 62, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-c26iqq62/overlay/lib/python3.5/site-packages/sipbuild/project.py", line 202, in apply_user_defaults
        self.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_defaults
        self._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.

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6963
  • Country: fi
    • My home page and email address
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #1 on: January 22, 2020, 05:36:06 am »
In current Ubuntu variants, the Python3 Qt5 bindings are in a package named python3-pyqt5 (but you'll also want to install python3-pyqt5.qtsvg, python3-pyqt5.qtwebkit, and python3-pyqt5.qtopengl). So, try running
    sudo apt install python3-pyqt5 python3-pyqt5.{qtsvg,qtwebkit,qtopengl}
instead.  (Note the extra py in python3-pyqt5.)

Let me know if this does not fix the issue for you.  (If not, please include the output of cat /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 a libpyqt5.so plugin for the Qt designer) are provided by python3-pyqt5 or python3-pyqt5.* on 18.04.
« Last Edit: January 22, 2020, 05:49:03 am by Nominal Animal »
 
The following users thanked this post: ebclr, Mr. Scram

Offline rx8pilotTopic starter

  • Super Contributor
  • ***
  • Posts: 3644
  • Country: us
  • If you want more money, be more valuable.
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #2 on: January 22, 2020, 06:00:32 am »
In current Ubuntu variants, the Python3 Qt5 bindings are in a package named python3-pyqt5 (but you'll also want to install python3-pyqt5.qtsvg, python3-pyqt5.qtwebkit, and python3-pyqt5.qtopengl). So, try running
    sudo apt install python3-pyqt5 python3-pyqt5.{qtsvg,qtwebkit,qtopengl}
instead.  (Note the extra py in python3-pyqt5.)

WOW!!!!

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.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6963
  • Country: fi
    • My home page and email address
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #3 on: January 22, 2020, 06:55:14 am »
    sudo apt install python3-pyqt5 python3-pyqt5.{qtsvg,qtwebkit,qtopengl}
This worked immediately without any issue.
Excellent!

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 would recommend always doing an apt list first:
    apt list '*python3*qt5*'
or
    dpkg-query -l '*py*qt5*'
Then, when you see interestingly-named packages, check them via
    apt show python3-pyqt5

Personally, I like the Synaptic GUI (in X) package manager interface better.  Just sudo 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.

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?
Using 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-line apt tools only is pretty obscure and lots of work; that's why Synaptic was developed in the first place.  If you don't have X (and are, say, SSH'ing to it), then use Aptitude, 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 out exactly what to install is 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 of always first do a search on the package manager instead 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 names seem universal, 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.
« Last Edit: January 22, 2020, 07:00:42 am by Nominal Animal »
 

Offline djnz

  • Regular Contributor
  • *
  • Posts: 179
  • Country: 00
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #4 on: January 30, 2020, 10:31:18 am »
I'd also suggest

Code: [Select]
sudo apt install build-essential

I 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: [Select]
cd project_dir

# setup a virtual environment in the venv directory
python3 -m venv venv

# use the virtual environment
source venv/bin/activate

and then the actual stuff. You can verify that you are using the virtual environment versions by something like

Code: [Select]
type python
type pip

and it should confirm that the ones in the virtual environment are being used.
« Last Edit: February 02, 2020, 07:25:39 pm by djnz »
 

Offline ebastler

  • Super Contributor
  • ***
  • Posts: 7131
  • Country: de
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #5 on: February 02, 2020, 04:51:08 pm »
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?

Not sure what you were looking for? When I Google "python qt5 ubuntu", the first two hits are
https://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ff and
https://stackoverflow.com/questions/36757752/how-to-install-pyqt5-in-python-3-ubuntu-14-04.

Both explain that you want to
Code: [Select]
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?
 

Offline rx8pilotTopic starter

  • Super Contributor
  • ***
  • Posts: 3644
  • Country: us
  • If you want more money, be more valuable.
Re: Installing Qt5 / PyQt5 Linux on FriendlyElec NanoPi
« Reply #6 on: February 03, 2020, 12:58:34 am »
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?

Not sure what you were looking for? When I Google "python qt5 ubuntu", the first two hits are
https://gist.github.com/ujjwal96/1dcd57542bdaf3c9d1b0dd526ccd44ff and
https://stackoverflow.com/questions/36757752/how-to-install-pyqt5-in-python-3-ubuntu-14-04.

Both explain that you want to
Code: [Select]
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?

The answer is always easier to find when you Google the right answer  :-DD

I 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: [Select]
sudo apt-get install PyQt-5 which never worked. I never recall seeing anything suggesting:
Code: [Select]
sudo apt-get install Python3-Qt5
and definitely did not know of any dependencies like what @Nominal Animal suggested.
Code: [Select]
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).
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf