aarch平台是无法通过pip安装PySide2的,同时利用源码下载一直报错
1. 我是python3.6.9,在官网上找到对应的PySide2版本 5.15.2.所以首先在官网下载Qt5.15.2的源码:https://download.qt.io/archive/qt/5.15/5.15.2/single/
2. 编译qt环境
aarch64-linux-gnu- # 查看g++版本
sudo apt-get update
sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev gdb cmake libxcb-xinerama0-dev libfontconfig1-dev libfreetype6-dev '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev # 编译QT环境
tar xvf qt-everywhere-src-5.15.2.tar.xz # 输入命令 tar xvf 解包。
cd qt-everywhere-src-5.15.2 # 进入源码文件目录
3.编译安装Qt5.15.2
./configure -xcb(不能加sudo) # Choose “o” 和‘y’
make -j4
sudo make install
4. 更新环境变量
更新你的 PATH 环境变量,以便可以在任何位置运行 Qt 程序。通过编辑你的 shell 配置文件
~/.bashrc 或 ~/.zshrc
echo 'export PATH=/usr/local/Qt-5.15.2/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
5. 通过终端安装一个QtCreator或者源码编译QtCreator:
sudo apt-get install qtcreator # 终端编译
git clone --recursive https://code.qt.io/qt-creator/qt-creator.git # 源码编译
6. 下载PySide2安装包(Install PySide2 from whl)
git clone https://github.com/chentongwilliam/PySide2-jetson-nano.git
cd PySide2-jetson-nano
pip3 install shiboken2-5.15.2.1-5.15.3-cp36-cp36m-linux_aarch64.whl
pip3 install shiboken2_generator-5.15.2.1-5.15.3-cp36-cp36m-linux_aarch64.whl
pip3 install PySide2-5.15.2.1-5.15.3-cp36-cp36m-linux_aarch64.whl
7. 从源码安装PySide2 from Source
环境要求:
General requirements: Python: 3.5+, Qt: 5.12+, libclang: version10, CMake:3.1+, llvm: version10(clang10)
sudo apt install libclang-10-dev
sudo apt install llvm
sudo apt-get install synaptic
synaptic
git clone https://code.qt.io/pyside/pyside-setup # python3.6版本
cd pyside-setup
git branch --track 5.12 origin/5.12
git checkout 5.12
find / -name 'qmake' # 可以用find / -name 'qmake'找到qmake的位置
python setup.py install --qmake=/usr/local/Qt-5.15.2/bin/qmake --parallel=8 --build-tests
8. 其他方法
在Ubuntu下编译安装PySide2的步骤:
1. 安装Qt5及相关依赖库:
sudo apt install qtbase5-dev qttools5-dev-tools libqt5svg5-dev libxml2-dev libxslt1-dev
2. 安装PySide2的依赖库:
sudo apt install libxcb-xinerama0-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-render-util0-dev libxcb-xkb-dev libxkbcommon-x11-dev libxkbcommon-dev libfontconfig1-dev libfreetype6-dev libpng-dev libjpeg-dev libglib2.0-dev libicu-dev
3. 安装CMake:
sudo apt install cmake
4. 下载PySide2源代码:
git clone https://code.qt.io/pyside/pyside-setup.git
cd pyside-setup
git submodule update --init --recursive
5. 构建安装PySide2:
mkdir build
cd build
cmake ..
make
sudo make install
9.测试
完成安装后,可以在Python中导入PySide2模块进行测试
python
import PySide2.QtWidgets