1.如何安装python3.7
参考:博客
https://blog.csdn.net/u013042928/article/details/86487579
https://www.cnblogs.com/wangyuxing/p/10542330.html
https://www.cnblogs.com/liunaixu/p/7814125.html
一、更新系统
sudo apt-get update
sudo apt-get upgrade
二、安装Python依赖
sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev
三、下载安装包
一个是Python2 ,一个是Python3,选择一个
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
或者
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
四、解压
tar -zxf Python-2.7.13.tgz
五、编译安装
cd Python-2.7.13
./configure
make && make install
六、建立连接(如果已经安装了之前的,可以先备份)
cd/usr/bin/
rm-rf python
ln-s /usr/local/Python-2.7/bin/python./python
或者
ln -s /usr/local/bin/python2.7 /python
七、树莓派上安装GPIO包
sudo apt-get install python-setuptools python-pip python-dev
pip install RPi.GPIO
安装smbus包
sudo apt-get install python-smbus
————————————————
版权声明:本文为CSDN博主「韦小龙」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u013042928/article/details/86487579
八:异常
出现错误:
ModuleNotFoundError: No module named '_ctypes'
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev opensslsudo apt-get install libffi-dev
我运行了最后一句代码……,发现还是不行,然后发现以下这个:
ubuntu默认软件包管理器不是yum,而是dpkg,安装软件时用apt-get你说的网上常见法解决方法,命令改为代码:
sudo apt-get install libxpm-dev libxext-dev 就行了
接下来创建软连接,注意:软连接的源文件是安装目录下的bin文件下的python3.7
sudo ln -s /usr/local/bin/python3.7/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/bin/python3.7/bin/pip3.7 /usr/bin/pip3.7