BlueHost安装Python3教程

redmaomail 2024-07-25 13:09 阅读数 78 #BlueHost

红帽云邮外贸主机

Python是世界上最受欢迎的编程语言之一,它是一种通用的语言,用于构建从简单的笔迹到复杂的机器学习算法的各种应用程序。那么BlueHost如何安装Python3,下面简单给大家简单介绍下。

一、BlueHost安装Python3(Ubuntu系统)

使用apt在Ubuntu上安装Python 3.9是一个相对简单的过程,只需几分钟即可完成。

1、更新软件包列表并安装必备组件:

sudo apt update

sudo apt install software-properties-common

2、将Deadsnakes PPA添加到系统的源列表中:

sudo add-apt-repository ppa:deadsnakes/ppa

出现提示时,按[Enter]以继续。

3、启用存储库后,您可以通过执行以下命令安装Python 3.9:

sudo apt install python3.9

4、通过键入以下命令验证安装是否成功:

python3.9 --version
Output

Python 3.9.0+

二、BlueHost安装Python3(Debian系统)

在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

红帽云邮外贸主机

分享到:
版权声明:本站内容源自互联网,如有内容侵犯了你的权益,请联系删除相关内容。
    红帽云邮外贸主机
热门
    红帽云邮外贸主机
    红帽云邮外贸主机