简体   繁体   English

如何在 debian 10 上安装 python3.8?

[英]How to Install python3.8 on debian 10?

i've installed debian 10.0.4 yesterday on my pc.我昨天在我的电脑上安装了debian 10.0.4

it had python version 3.7.3 installed on it, so i tried to update it to version 3.8.3 and now i have version 3.8.3 installed but when i try to install pip using the official get-pip.py it throws an exception.它安装了python version 3.7.3 ,所以我尝试将其更新到3.8.3版本,现在我安装了3.8.3版本,但是当我尝试使用官方get-pip.py安装 pip 时,它会引发异常. the details is:详情是:

Traceback (most recent call last):
  File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen zipimport>", line 568, in _get_data
  File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "get-pip.py", line 23484, in <module>
    main()
  File "get-pip.py", line 198, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "<frozen zipimport>", line 241, in load_module
  File "<frozen zipimport>", line 709, in _get_module_code
  File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available

i must mention that the python (python2.7) and pip for python 2.7 is working, and i tried to reinstall python using source compilation and i got another error while installing it (zlib error) i must mention that the python (python2.7) and pip for python 2.7 is working, and i tried to reinstall python using source compilation and i got another error while installing it (zlib error)

Installing Python 3.8 on Debian 10在 Debian 10 上安装 Python 3.8

Building Python 3.8 on Debian is a relatively straightforward process and will only take a few minutes.在 Debian 上构建 Python 3.8 是一个相对简单的过程,只需几分钟。

  1. Start by installing the packages necessary to build Python source:首先安装构建 Python 源代码所需的软件包:
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
  1. Download the latest release's source code from the Python download page with wget or curl.使用 wget 或 curl 从 Python 下载页面下载最新版本的源代码。 At the time of writing this article, the latest release is 3.8.2:在撰写本文时,最新版本是 3.8.2:
curl -O https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz
  1. When the download is complete, extract the tarball:下载完成后,解压压缩包:
tar -xf Python-3.8.2.tar.xz
  1. Navigate to the Python source directory and run the configure script:导航到 Python 源目录并运行配置脚本:
cd Python-3.8.2
./configure --enable-optimizations --enable-loadable-sqlite-extensions

The script performs a number of checks to make sure all of the dependencies on your system are present.该脚本执行许多检查以确保系统上的所有依赖项都存在。 The --enable-optimizations option will optimize the Python binary by running multiple tests, which will make the build process slower. --enable-optimizations 选项将通过运行多个测试来优化 Python 二进制文件,这将使构建过程变慢。

  1. Run make to start the build process:运行 make 开始构建过程:
make -j 4

Modify the -j to correspond to the number of cores in your processor.修改-j以对应处理器中的内核数。 You can find the number by typing nproc .您可以通过键入nproc找到该号码。

  1. Once the build is done, install the Python binaries by running the following command as a user with sudo access:构建完成后,通过以具有 sudo 访问权限的用户身份运行以下命令来安装 Python 二进制文件:
sudo make altinstall

Do not use the standard make install as it will overwrite the default system python3 binary.不要使用标准的make install ,因为它会覆盖默认的系统python3二进制文件。

  1. At this point, Python 3.8 is installed on your Debian system and ready to be used.至此,Python 3.8 已安装在您的 Debian 系统上并可以使用了。 You can verify it by typing:您可以通过键入以下内容来验证它:
python3.8 --version
Python 3.8.2

source: https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/来源: https://linuxize.com/post/how-to-install-python-3-8-on-debian-10/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM