Ubuntu 22.04安装Python3.10.13

Ubuntu最好设置为英文,我之前用中文在make的test的时候,总是会有fail。

查了下有人怀疑是language的问题,保险起见都用英文,个人实践也证明改为英文就不报错了。

issue 44031: test_embed and test_tabnanny fails if the current directory is non-ASCII - Python trackericon-default.png?t=N7T8https://bugs.python.org/issue44031

1.下载Python3.10.13

Python Release Python 3.10.13 | Python.orgicon-default.png?t=N7T8https://www.python.org/downloads/release/python-31013/得到Python-3.10.13.tgz

2.解压Python-3.10.13.tgz

3.进入Python-3.10.13目录打开终端

先安装依赖的包

(很重要!!否则会在make install时出现make: *** [Makefile:1280: install] Error 1)

installation - make: *** [Makefile:1280: install] Error 1 - Stack Overflowicon-default.png?t=N7T8https://stackoverflow.com/questions/70848502/make-makefile1280-install-error-1

$ sudo apt install build-essential
$ sudo apt install libssl-dev libffi-dev libncurses5-dev zlib1g zlib1g-dev libreadline-dev libbz2-dev libsqlite3-dev make gcc

 再安装Python

$ ./configure --enable-optimizations
$ make
$ sudo make install

========================

安装成功之后,会提示一个pip相关信息,且使用pip时会提示Command 'pip' not found

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

原因是

这意味着一个 Python 安装可能无法满足 每个应用程序的要求。如果应用程序 A 需要版本 1.0 的特定模块,但应用程序 B 需要 2.0 版本,然后 要求与安装 1.0 版或 2.0 版之间存在冲突 将使一个应用程序无法运行。

这个问题的解决方案是创建一个虚拟环境,一个 包含 Python 安装的独立目录树 特定版本的 Python,以及一些额外的包。

pip从版本10开始禁止在没有虚拟环境的情况下进行安装。

按照https://pip.pypa.io/warnings/venv的方式,在项目目录新建 virtual environment ,来使用pip

项目目录打开终端

为虚拟环境创建一个目录tutorial-env,这个可以自己指定名字

python -m venv tutorial-env

激活

source tutorial-env/bin/activate

不想用了就关闭

deactivate

相关推荐

  1. Ubuntu 下 Docker安装 2024

    2024-03-26 18:06:02       28 阅读
  2. ubuntu 安装python3.10

    2024-03-26 18:06:02       64 阅读
  3. ubuntu24安装python2

    2024-03-26 18:06:02       28 阅读
  4. Ubuntu2204安装小熊猫C++/DevCpp

    2024-03-26 18:06:02       75 阅读
  5. ubuntu2204,mysql8.x安装

    2024-03-26 18:06:02       59 阅读
  6. ubuntu22安装python3虚拟环境

    2024-03-26 18:06:02       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-26 18:06:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-26 18:06:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-26 18:06:02       87 阅读
  4. Python语言-面向对象

    2024-03-26 18:06:02       96 阅读

热门阅读

  1. ubuntu 22.04 LTS 内核从 5.15.0 升级到 6.6.0

    2024-03-26 18:06:02       42 阅读
  2. PHP学习笔记

    2024-03-26 18:06:02       32 阅读
  3. Spring Boot

    2024-03-26 18:06:02       38 阅读
  4. linux安装指定版本docker

    2024-03-26 18:06:02       45 阅读
  5. Python中,type() 和 isinstance() 的区别

    2024-03-26 18:06:02       44 阅读
  6. 12、Spring CLI中的角色使用

    2024-03-26 18:06:02       37 阅读
  7. leetcode ——匹配子序列的单词数

    2024-03-26 18:06:02       45 阅读
  8. Python如何查询es里的数据

    2024-03-26 18:06:02       33 阅读
  9. uniapp先显示提示消息再返回上一页

    2024-03-26 18:06:02       36 阅读