title: How to install PySide2 in a Python3 virtual environment on Raspberry Pi3
body: <p>I am having a hard time installing PySide2 in a Python3 virtual enviroment on a Raspberry Pi3. I use <em>Python-3.5.3</em> and the updated version of <em>pip</em>.</p>
  
  <pre><code>(cv3) pi@raspberrypi:~ $ which cmake
  /usr/bin/cmake
  (cv3) pi@raspberrypi:~ $ which qmake
  /usr/bin/qmake
  (cv3) pi@raspberrypi:~ $ which python
  /home/pi/.virtualenvs/cv3/bin/python
  (cv3) pi@raspberrypi:~ $ python --version
  Python 3.5.3
  (cv3) pi@raspberrypi:~ $ pip --version
  pip 19.0.1 from /home/pi/.virtualenvs/cv3/lib/python3.5/site-packages/pip (python 3.5)
  (cv3) pi@raspberrypi:~ $ pip3 --version
  pip 19.0.1 from /home/pi/.virtualenvs/cv3/lib/python3.5/site-packages/pip (python 3.5)
  </code></pre>
  
  <p>First I tried to install with pip install PySide2 but I got the error</p>
  
  <pre><code>(cv3) pi@raspberrypi:~ $ pip install PySide2
  Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
  Collecting PySide2
  Could not find a version that satisfies the requirement PySide2 (from versions: )
  No matching distribution found for PySide2
  </code></pre>
  
  <p>Following the instructions found at <a href="https://wiki.qt.io/Qt_for_Python/GettingStarted" rel="nofollow noreferrer">https://wiki.qt.io/Qt_for_Python/GettingStarted</a> on how to install via the official release wheels of Qt for Python also gives an error.</p>
  
  <pre><code>(cv3) pi@raspberrypi:~ $ pip install --index-url=https://download.qt.io/official_releases/QtForPython/ pyside2 --trusted-host download.qt.io
  Looking in indexes: https://download.qt.io/official_releases/QtForPython/, https://www.piwheels.org/simple
  Collecting pyside2
  Could not find a version that satisfies the requirement pyside2 (from versions: )
  No matching distribution found for pyside2
  </code></pre>
  
  <p>Then I followed the instructions on the official package site <a href="https://pypi.org/project/PySide2/" rel="nofollow noreferrer">https://pypi.org/project/PySide2/</a>. I installed the dependencies, including <em>libclang</em> and build from source as suggested without any errors.</p>
  
  <pre><code>git clone https://code.qt.io/pyside/pyside-setup
  cd pyside-setup
  git branch --track 5.12 origin/5.12
  git checkout 5.12
  python setup.py install --qmake=&lt;/usr/bin/qmake/&gt; --parallel=8 --build-tests
  </code></pre>
  
  <p>Yet after all this work, there are no signs of the module PySide2</p>
  
  <pre><code>(cv3) pi@raspberrypi:~/pyside-setup $ python
  Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
  [GCC 6.3.0 20170516] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import PySide2
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: No module named 'PySide2'
  &gt;&gt;&gt;
  </code></pre>
  
  <p>Next thing I followed the instructions found on <a href="https://wiki.qt.io/Qt_for_Python/GettingStarted/X11" rel="nofollow noreferrer">https://wiki.qt.io/Qt_for_Python/GettingStarted/X11</a>. I clone the official repository, checked the versions are fine and then build using the <em>qmake</em> path /opt/Qt5.12/bin/qmake:</p>
  
  <pre><code>(cv3) pi@raspberrypi:~/pyside-setup $ python setup.py build --qmake=/opt/Qt5.12/bin/qmake --parallel=4 --build-tests --ignore-git
  </code></pre>
  
  <p>and the build gave two errors:
      CMake Error at CMakeLists.txt:95 (message):
      Unable to detect CLANG location by checking LLVM_INSTALL_DIR, CLANG_INSTALL_DIR or running llvm-config.</p>
  
  <pre><code>-- Configuring incomplete, errors occurred!
  See also "/home/pi/pyside-setup/cv33_build/py3.5-qt5.12.0-32bit-release/shiboken2/CMakeFiles/CMakeOutput.log".
  error: Error configuring shiboken2
  </code></pre>
  
  <p>I guessed perhaps updating <em>CLANG</em> and <em>CMAKE</em> will make a change. So I did the update to the latest version and the process went well without errors. Then I </p>
  
  <p>While building PySide2 the process exits at 47% with the following error:</p>
  
  <pre><code>[ 47%] Linking CXX executable shiboken2
  /home/pi/libclang/lib/libclang.so: file not recognized: File format not recognized
  collect2: error: ld returned 1 exit status
  generator/CMakeFiles/shiboken2.dir/build.make:181: set di istruzioni per l'obiettivo "generator/shiboken2" non riuscito
  make[2]: *** [generator/shiboken2] Errore 1
  CMakeFiles/Makefile2:2877: set di istruzioni per l'obiettivo "generator/CMakeFiles/shiboken2.dir/all" non riuscito
  make[1]: *** [generator/CMakeFiles/shiboken2.dir/all] Errore 2
  Makefile:140: set di istruzioni per l'obiettivo "all" non riuscito
  make: *** [all] Errore 2
  error: Error compiling shiboken2
  Traceback (most recent call last):
  File "setup.py", line 296, in &lt;module&gt;
  setup_runner.run_setup()
  File "/home/pi/pyside-setup/build_scripts/setup_runner.py", line 157, in run_setup
  raise RuntimeError(msg)
  RuntimeError: 
  setup.py invocation failed with exit code: 1.
  
  
  setup.py invocation was: /home/pi/.virtualenvs/cv3/bin/python setup.py build --qmake=/opt/Qt5.12/bin/qmake --parallel=4 --build-tests --ignore-git --internal-build-type=shiboken2
  </code></pre>
  
  <p>Where is the problem?</p>