首页 > 系统相关 >ubuntu20.04 python3.7

ubuntu20.04 python3.7

时间:2023-07-25 17:01:55浏览次数:33  
标签:ubuntu20.04 3.7 Python dev python3.7 Ubuntu 安装 20.04

Ubuntu 20.04 中使用 Python 3.7

Ubuntu 20.04 是一种广泛使用的 Linux 操作系统版本,它提供了强大的开发环境和工具。Python 是一种流行的编程语言,适用于各种应用场景。在 Ubuntu 20.04 上安装和使用 Python 3.7 版本非常简单。

下面将介绍如何在 Ubuntu 20.04 上安装 Python 3.7,并演示一些基本的代码示例。

安装 Python 3.7

要在 Ubuntu 20.04 上安装 Python 3.7,可以通过以下步骤进行操作:

  1. 打开终端,可以使用快捷键 Ctrl + Alt + T
  2. 更新系统软件包列表:
sudo apt update
  1. 安装 Python 3.7 的依赖库:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
  1. 下载 Python 3.7 的源代码包:
wget 
  1. 解压源代码包:
tar -xf Python-3.7.10.tgz
  1. 进入解压后的目录:
cd Python-3.7.10
  1. 配置并编译 Python 3.7:
./configure --enable-optimizations
make -j8
  1. 安装 Python 3.7:
sudo make altinstall

现在,Python 3.7 已经成功安装在 Ubuntu 20.04 上。

使用 Python 3.7

安装完成后,我们可以测试一下 Python 3.7 的运行情况。在终端中输入以下命令:

python3.7 --version

如果输出类似于 Python 3.7.10 的信息,则说明 Python 3.7 已经成功安装。

接下来,让我们编写一个简单的 Python 程序。在终端中创建一个新的文件,并命名为 hello.py

nano hello.py

然后,将以下代码粘贴到文件中:

print("Hello, Ubuntu 20.04 with Python 3.7!")

保存并关闭文件。现在,我们可以运行这个程序了:

python3.7 hello.py

你将会看到输出结果为 Hello, Ubuntu 20.04 with Python 3.7!

除了运行简单的程序,Python 3.7 还提供了丰富的标准库和第三方库,可以用于开发各种应用。你可以使用以下命令安装和管理 Python 包:

pip3.7 install package_name  # 安装包
pip3.7 uninstall package_name  # 卸载包
pip3.7 freeze  # 显示已安装的包及其版本信息

例如,安装常用的数据分析库 pandas:

pip3.7 install pandas

结论

在本文中,我们了解了如何在 Ubuntu 20.04 上安装和使用 Python 3.7。通过这个版本的 Python,你可以使用最新的语言特性和库来开发各种应用程序。Python 3.7 的安装过程相对简单,并且可以通过包管理器 pip3.7 方便地安装和管理软件包。

希望本文对你在 Ubuntu 20.04 上使用 Python 3.7 提供了帮助。祝你编写出更多优秀的 Python 代码!

标签:ubuntu20.04,3.7,Python,dev,python3.7,Ubuntu,安装,20.04
From: https://blog.51cto.com/u_16175526/6847011

相关文章

  • [Linux系统] 使用WSL2下的Ubuntu20.04
    一、安装WSL2下的Ubuntu20.04 1)打开windowsWSL服务#以管理员身份运行PowerShelldism.exe/online/enable-feature/featurename:Microsoft-Windows-Subsystem-Linux/all/norestartdism.exe/online/enable-feature/featurename:VirtualMachinePlatform/all/norest......
  • [踩坑] WSL2 Ubuntu20.04启用systemctl
    一、安装fontconfigdaemonizesudoaptinstall-yfontconfigdaemonize二、修改/etc/profile#在末尾添加以下内容SYSTEMD_PID=$(ps-ef|grep'/lib/systemd/systemd--system-unit=basic.target$'|grep-vunshare|awk'{print$2}')if[-z"$SYST......
  • Linux下编译安装python3.7 附带python-dev
    1、安装开发工具包sudoyum-ygroupinstall"Developmenttools" 2、安装依赖包sudoyum-yinstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgdbm-develdb4-devellibpcap-develxz-devellibffi-devel ......
  • ubuntu18.04、ubuntu20.04桌面版换国内源
    ubuntu18.04、ubuntu20.04桌面版换国内源一、ubuntu18.04换源1.备份原始源文件source.list2.修改源文件二、ubuntu20.04换源三、其他换源方法安装好ubuntu18.04或ubuntu20.04后,软件更新默认使用国外源,在国内更新时速度很慢,所以需要更换成国内源,这样软件的更新和安装才......
  • ubuntu20.04安装Kubernetes(k8s)
    1.禁止swap分区(必须)暂时禁止:sudoswapoff-a永久禁止:#注释掉swap一行sudovi/etc/fstab2.更改net.bridge.bridge-nf-call-iptables的值为1.(Ubuntu20.04默认为1)cat<<EOF|sudotee/etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-ip6tables=1net.bridge.br......
  • ubuntu20.04使用plx9054官方驱动 转载
    转载地址http://wuhongyi.cn/PKUXIADAQ/en/INSTALL.htmlInstallationofSoftwareInstallationforthissoftwareisrequriredbyCERNROOT6GCC>=4.8FFTW3OPENSSLTheoperatingsystemtestedbythisprogramincludesCentOS7/ScientificLinux7/......
  • 利用U盘给Intel NUC重装Ubuntu20.04系统
    背景因为社团里刚好有一个被玩坏的IntelNUC,我又刚好对此感兴趣,于是学长就交给我这一项任务,让我给这台NUC刷机。目录NUC刷机基本上简单分为四步一、格式化U盘二、下载Ubuntu20.04系统镜像三、将系统镜像写入U盘,制成启动盘四、把启动盘里的系统整到NUC里,重装系统,完成刷机。......
  • ubuntu20.04 配置编译安装nginx的systemctl启动命令
    vim/usr/lib/systemd/system/nginx.service[Unit]Description=nginx-highperformancewebserverAfter=network.targetremote-fs.targetnss-lookup.target[Service]Type=forkin......
  • ubuntu20.04安装mongodb步骤
    注:虚拟机无法运行mongodb5.0以上的版本1、wget-qO-https://www.mongodb.org/static/pgp/server-4.4.asc|apt-keyadd-导入并设置公钥2、echo"deb[arch=amd64,arm64]https://repo.mongodb.org/apt/ubuntufocal/mongodb-org/4.4multiverse"|tee/ect/apt/sources.list.......
  • Ubuntu20.04 开机卡在“starting Gnome Display Manager”
    今天ubuntu开机遇到了该问题:解决方法:https://blog.csdn.net/qq_42680785/article/details/116195840sudoaptautoremove--purgesnapd//清理磁盘空间......