在树莓派上安装wxpython(来自csdn的bd7iow---转自国外博客)

重新编辑:
前几天不小心把树莓派的内存卡格式化,工作一下子回到解放前。。幸好wxpython已经编译好whl包了。。重新下载树莓派系统,我这次选择树莓派官方最新系统(上次系统为2017年的),日期2020年2月份的buster版本,新版本自带py3.7,只需更新pip,同时更换为清华的源,之后按照下面的步骤安装依赖(过程顺利无下面提到的其他问题),完啦确认six,pillow,numpy包之后直接pip安装wxpython,过程非常快,直接无错误安装好并且能运行wxpython的demo.py。。。。下面的图就不更新了,赶紧备份一下TF卡先。。。。。。。
################################################
If you need to install wxPython on Raspbian Buster for a project, the installation of that module can be a little bit tricky. It needs to be compiled for Raspbian from source files to have something working nicely.

Here you can find step by step explaination how to do it.

Requirements
Raspberry Pi
Python 3.x
time, lots of time

Step 1
First, you need to open a terminal (shortcut ctrl + alt + t)

sudo apt-get update

sudo apt-get install dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev libgstreamer-plugins-base0.10-dev libnotify-dev freeglut3 freeglut3-dev libwebkitgtk-dev libghc-gtk3-dev libwxgtk3.0-gtk3-dev

(libgstreamer-plugins-base0.10-dev这个换到国内源可能安装失败,查过资料是有最新版的可以用)
if you use the pre-installed Python 3:

sudo apt-get install python3.7-dev

Step 2
Now, let’s make the virtual environment. I made mine right off the /home/pi directory, but you can put it anywhere. Some like to put all their virtual environments (virtenv) in specific locations.

Let’s make one (wx is the name of the virtenv we are creating, change it to suit):

cd ~

python3 -m venv wx

source ~/wx/bin/activate

Step 3
The first thing you need is wxPython.

Go to:

https://pypi.org/project/wxPython/#files

Down of the bottom of the choices, you will see “wxPython-4.1.0.tar.gz … Source”.

Download wxPython-4.1.0.tar.gz

Use your browser if you can. The file should go into your ~/Downloads folder. The link currently is the very human unfriendly:

下载wxpython4.1.0源码

Okay, that’s not exactly a professional comment but sometimes you just have to call it what it is.

cd ~

mv ~Downloads/wxPython-4.1.0.tar.gz

tar xf wxPython-4.1.0.tar.gz

Next step, make sure you are in the environment you want to install wxPython into.

cd wxPython-4.1.0

pip3 install -r requirements.txt

The next part is the big one. This will take a while, anywhere from a few hours to 18+ hours on a Raspberry Pi Zero.

python3 build.py build bdist_wheel --jobs=2(这里是用多少线程编译,我用3B,=4的话会卡死,用2刚好)

After waiting ~ 8 hours
Now to install it in Python as a package (the name of this file varies depending on the Python version you build it with. ie. wxPython-4.1.0-cp38-cp38-linux_armv7l.whl for Python 3.8(命名看每个人的环境吧)) :

cd ~/wxPython-4.1.0/dist

pip3 install wxPython-4.1.0-cp37-cp37m-linux_armv7l.whl

After waiting ~ 1 hour
Now let’s test it:

cd ~/wxPython-4.1.0.post2/demo

python3 demo.py

Enjoy
下面两个截图是wxpython源码中自带的demo,这个demo包含了wx很多控件的使用例子,虽然可能wx界面没qt的那么灵活,那么好看。但是我个人觉得wx够简单,例子也丰富,像我这样的菜鸡也能玩得起来。
demo1
demo2我自己3B上编译的whl文件上传到我的资源上,有兴趣的可以下载来玩玩。。。但是不保证能在你的机器上运行,也不提供技术支持。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值