分享最新优惠信息
购买主机更加划算

Debian 10系统安装Python 3.9版本详细过程介绍

Python是一种OSI认证的编程和脚本语言,可自由使用和分发,甚至可用于商业用途,开发管理和控制在Python Software Foundation之下。在本文更新时,Python的最新版本是3.9.x,这里将演示Linux用户怎样在Debian 10系统上安装Python 3.9版本。

Python是一种易于学习的语言,其语法简洁简洁,是新手和有经验的开发人员的第一选择。Python可用于构建桌面应用程序、自动化脚本、Web应用程序、游戏、大数据应用程序等。Python开发旅程的第一步就是进行软件的安装。

在Debian 10上安装Python 3.9

在Debian 10系统上安装Python 3.9之前,请更新系统APT缓存索引,命令如下:

sudo apt update

如果可以升级的话,请运行以下命令。

sudo apt upgrade -y

成功升级后,然后重新启动系统。

sudo reboot

重新启动系统之后,安装依赖项软件包:

sudo apt install wget software-properties-common build-essential libnss3-dev zlib1g-dev libgdbm-dev libncurses5-dev   libssl-dev libffi-dev libreadline-dev libsqlite3-dev libbz2-dev

y键开始安装:

0 upgraded, 95 newly installed, 0 to remove and 0 not upgraded.
Need to get 74.7 MB of archives.
After this operation, 296 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

可以访问“ Python下载”页面并获取最新版本,这里下载最新的Python 3.9.2版本。

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

解压缩下载的文件,命令如下:

tar xvf Python-3.9.2.tgz

更改工作目录以创建Python文件夹:

cd Python-3.9.2/

运行配置命令

./configure --enable-optimizations

样本输出:

....
checking for shm_open... yes
checking for shm_unlink... yes
checking for pkg-config... no
checking for openssl/ssl.h in /usr/local/ssl... no
checking for openssl/ssl.h in /usr/lib/ssl... no
checking for openssl/ssl.h in /usr/ssl... no
checking for openssl/ssl.h in /usr/pkg... no
checking for openssl/ssl.h in /usr/local... no
checking for openssl/ssl.h in /usr... no
checking whether compiling and linking against OpenSSL works... no
checking for --with-ssl-default-suites... python
checking for --with-builtin-hashlib-hashes... md5,sha1,sha256,sha512,sha3,blake2
configure: creating ./config.status
config.status: creating Makefile.pre
config.status: creating Misc/python.pc
config.status: creating Misc/python-embed.pc
config.status: creating Misc/python-config.sh
config.status: creating Modules/ld_so_aix
config.status: creating pyconfig.h
config.status: pyconfig.h is unchanged
creating Modules/Setup.local
creating Makefile

在Debian 10系统上构建Python 3.9,命令如下:

sudo make altinstall

成功的安装的话,将具有类似于以下的输出:

....
changing mode of /usr/local/lib/python3.9/lib-dynload/__pycache__ to 755
running install_scripts
copying build/scripts-3.9/idle3.9 -> /usr/local/bin
copying build/scripts-3.9/pydoc3.9 -> /usr/local/bin
copying build/scripts-3.9/2to3-3.9 -> /usr/local/bin
changing mode of /usr/local/bin/idle3.9 to 755
changing mode of /usr/local/bin/pydoc3.9 to 755
changing mode of /usr/local/bin/2to3-3.9 to 755
rm /usr/local/lib/python3.9/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.9/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
	/usr/local/share/man/man1/python3.9.1
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--altinstall --upgrade" ;; \
		install|*) ensurepip="--altinstall" ;; \
	esac; \
	 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpog4qrruc
Requirement already up-to-date: setuptools in /usr/local/lib/python3.9/site-packages (49.2.1)
Requirement already up-to-date: pip in /usr/local/lib/python3.9/site-packages (20.2.3)

运行以下命令,这样会输出系统中可用的Python 3.9版本:

$ python3.9 --version
Python 3.9.2

要安装Python模块发布页面中可用的Python模块,请使用命令语法:

python3.9 -m pip install <module>

结论

在本教程中,简单给大家展示了如何在Debian 10系统中安装Python 3.9版本,安装过程仅供参考。

目前Python最新版本是3.9.2,如果后期版本有更新的话, 那么也可以按照上述教程进行安装,过程基本都是大同小异。

未经允许不得转载:惠主机 » Debian 10系统安装Python 3.9版本详细过程介绍

相关文章