我很难在Raspberry Pi3上的Python3虚拟环境中安装PySide2。我使用Python-3.53和pip的更新版本。
(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)
首先我尝试用pipinstallPySide2安装,但我得到了错误
(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
遵循上的说明https://wiki.qt.io/Qt_for_Python/GettingStarted关于如何通过Qt for Python的官方发布轮进行安装,也给出了一个错误。
(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
然后我按照官方包裹网站上的说明https://pypi.org/project/PySide2/.我安装了依赖项,包括libclang,并按照建议从源代码构建,没有任何错误。
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=</usr/bin/qmake/> --parallel=8 --build-tests
然而,在所有这些工作之后,没有迹象表明PySide2 模块
(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.
>>> import PySide2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PySide2'
>>>
接下来,我遵循了上的说明https://wiki.qt.io/Qt_for_Python/GettingStarted/X11.我克隆了官方存储库,检查了版本是否正常,然后使用qmake路径/opt/Qt5.12/bin/qmake:进行构建
(cv3) pi@raspberrypi:~/pyside-setup $ python setup.py build --qmake=/opt/Qt5.12/bin/qmake --parallel=4 --build-tests --ignore-git
构建中出现了两个错误:CMakeLists.txt:95处的CMake错误(消息):无法通过检查LLVM_INSTALL_DIR、CLANG_INSTALL.DIR或运行LLVM配置来检测CLANG位置。
-- 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
我猜更新CLANG和 CMAKE在构建PySide2时,进程以47%退出,并出现以下错误: 问题出在哪里?[ 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 <module>
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
由于安装的CLANG
版本已过期,我按照codepool.biz上的说明首先尝试更新它。没有出现任何问题。
然后,我再次使用将LLVM
和CLANG
库指向PySide2安装路径
export CLANG_INSTALL_DIR=/usr/local/clang_7.0.
export LLVM_INSTALL_DIR=/usr/local/clang_7.0.0
构建过程成功地通过了47%的树策略并完成了对shiboken2
的构建,但在2%的PySide2
步骤中陷入了困境。错误:
[ 2%] Built target pyside2
Makefile:140: set di istruzioni per l'obiettivo "all" non riuscito
make: *** [all] Errore 2
error: Error compiling pyside2
Traceback (most recent call last):
File "setup.py", line 296, in <module>
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=pyside2
发生了什么事?