问题描述
我需要树莓派中的python最新版本.
我试过 apt install python3 3.8
apt install python3
但这没有用.
而且我还需要更新我的树莓派 python IDLE
I need python newest version in raspberry pi.
I tried apt install python3 3.8
apt install python3
but this didnot work.
And I also needed to update my raspberry pi python IDLE
推荐答案
首先更新 Raspbian.
First update the Raspbian.
sudo apt-get update
然后安装先决条件,这将使 Python 和/或软件包的进一步安装更加顺畅.
Then install the prerequisites that will make any further installation of Python and/or packages much smoother.
sudo apt-get install -y build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev
然后安装 Python,也许通过下载压缩文件?
And then install Python, maybe by downloading a compressed file?
示例 1:
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
解压文件夹:
sudo tar zxf Python-3.8.0.tgz
进入文件夹:
cd Python-3.8.0
初始配置:
sudo ./configure --enable-optimizations
使用上述参数运行文件夹内的makefile:
Run the makefile inside the folder with the mentioned parameters :
sudo make -j 4
这次再次运行 makefile 直接安装包:
Run again the makefile this time installing directly the package :
sudo make altinstall
也许您已经这样做了,但您不知道如何将新版本设置为系统的默认版本?
Maybe You already did it but You don't know how to setup the new version as a default version of the system?
首先检查它是否已安装:
Check first that it has been installed :
python3.8 -V
向 .bashrc 发送一个强命令,告诉他谁(哪个版本)负责 Python
Send a strong command to .bashrc telling him who (which version) is in charge of Python
echo "alias python=/usr/local/bin/python3.8" >> ~/.bashrc
再来一次!告诉他,因为 .bashrc 必须理解!我在开玩笑 - 您必须提供文件的来源,以便可以立即应用更改:
Again! Tell him because .bashrc has to understand! I am joking - You have to source the file so the changes can be applied immediately :
source ~/.bashrc
然后检查您的系统是否将 Python 的默认版本更改为 Python 3.8
And then check that Your system changed the default version of Python to Python 3.8
python -V
失败取决于很多因素:安装了什么依赖项,添加到source_list.d的包是什么,安装过程中出现的一些不便.所有这些都可能为您提供比您想象的更多的信息,请仔细阅读.希望有帮助.
The failure depends on many factors : what dependencies are installed, what are the packages added to the source_list.d, some inconvenient coming up during the installation. All may give you more information than you think, just read carefully.Hope it helped.
这篇关于如何在树莓派中更新 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!