首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装的python3.9 3.9在linux中未显示

安装的python3.9 3.9在linux中未显示
EN

Stack Overflow用户
提问于 2022-02-23 14:00:43
回答 3查看 4K关注 0票数 2

我按照这个链接中的步骤安装了python3.9。

  1. sudo apt update
  2. sudo apt install python3.9
  3. python3.9
  4. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1
  5. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
  6. sudo update-alternatives --config python3

然而,它在第3点抛出了一个python3.9 not found错误。另外,我注意到了python3.9在安装时使用的第二点显示了Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'

完整消息是

代码语言:javascript
复制
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'
The following packages were automatically installed and are no longer required:
  linux-aws-headers-4.4.0-1104 linux-aws-headers-4.4.0-1105 linux-aws-headers-4.4.0-1106 linux-aws-headers-4.4.0-1107 linux-aws-headers-4.4.0-1109 linux-aws-headers-4.4.0-1110 linux-aws-headers-4.4.0-1111
  linux-aws-headers-4.4.0-1112 linux-aws-headers-4.4.0-1113 linux-aws-headers-4.4.0-1114
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  postgresql-plpython3-9.5
0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 0 B/40.6 kB of archives.
After this operation, 166 kB of additional disk space will be used.
Selecting previously unselected package postgresql-plpython3-9.5.
(Reading database ... 362651 files and directories currently installed.)
Preparing to unpack .../postgresql-plpython3-9.5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Processing triggers for postgresql-common (173ubuntu0.3) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Setting up postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...

为什么要设置PostgreSQLplpython3-9.5,我怎样才能阻止它这样做呢?

EN

回答 3

Stack Overflow用户

发布于 2022-05-13 09:20:44

问题是:

死蛇ppa不再适用于Ubuntu。这就是你不能安装python3.9的原因。参见问题。您必须从源代码编译或将您的服务器升级到受支持的Ubuntu版本。

解决方案:自己构建

如果您无法升级您的系统,您可以使用碧昂夫安装任何给定的python版本,如下所述。为此,需要为python >= 3.8安装一个新版本的openssl

代码语言:javascript
复制
# install dependencies
apt update
apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev liblzma-dev git

# download and compile openssl
curl -L https://www.openssl.org/source/openssl-1.1.1q.tar.gz | (cd /usr/src; tar xz)
cd /usr/src/openssl-1.1.1q && ./config --prefix=/usr/local && make -j4 && make install

# download and configure pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

echo >> ~/.bashrc # add new-line.
echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc

# build python 3.9.13 with pyenv
CONFIGURE_OPTS="--with-openssl=/usr/local --with-openssl-rpath=auto" pyenv install 3.9.13

# build python 3.10.5 with pyenv
CONFIGURE_OPTS="--with-openssl=/usr/local --with-openssl-rpath=auto" pyenv install 3.10.5
票数 6
EN

Stack Overflow用户

发布于 2022-02-23 14:32:09

你可能已经安装好了

尝试运行$ python3 --version以查看您运行的python版本。如果未安装,请尝试运行$ sudo apt-get update,然后运行$ sudo apt-get install python3.9以安装python3.9

希望这能帮上忙

票数 0
EN

Stack Overflow用户

发布于 2022-04-29 11:46:16

您将需要添加死蛇回购。

代码语言:javascript
复制
sudo add-apt-repository ppa:deadsnakes/ppa

在那之后,你可以按照你问题中的步骤。

如果在添加死蛇回购后仍然存在相同的问题,这可能意味着您运行的是不受支持的linux版本。然后您可能必须从源代码中安装Python3.9,您可以检查这个答案如何做到这一点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71238292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档