树莓派centos系统安装python3

python

树莓派的centos系统不带有python3,虽然自己下载源码编译安装,下面是方法:

1.安装wget

yum -y install wget

2.使用wget命令从官方网站下载python3的源码

wget https://www.python.org/ftp/python/3.5.7/Python-3.5.7.tgz

3.解压

tar -zxvf Python-3.5.7.tgz

4.cd到解压目录,然后运行配置

./configure --prefix=/usr/local/python3 --with-ssl

5.make

6.make install

7.将编译结果中的python可执行文件复制为python3,python3.5(这样可以直接用python3来调用python3,而使用python时默认调用python2.7)

cd  /usr/local/python3

cp python python3

cp python python3.5

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

源码编译安装的版本不带有pip,下面介绍如何安装pip

从pypi上下面pip压缩包

wget https://files.pythonhosted.org/packages/36/fa/51ca4d57392e2f69397cd6e5af23da2a8d37884a605f9e3f2d3bfdc48397/pip-19.0.3.tar.gz

解压

tar -zxvf pip-19.0.3.tar.gz

cd到解压目录,然后运行

python3 setup.py install

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

将/usr/local/python3/bin添加至$PATH

vim /etc/profile

在文件末尾添加 PATH=$PATH:/usr/local/python3/bin:/usr/local/python3

source /etc/profile

以上是 树莓派centos系统安装python3 的全部内容, 来源链接: utcz.com/z/388589.html

回到顶部