我按照这个链接中的步骤安装了python3.9。
sudo apt updatesudo apt install python3.9python3.9sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.[old-version] 1sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2sudo update-alternatives --config python3然而,它在第3点抛出了一个python3.9 not found错误。另外,我注意到了python3.9在安装时使用的第二点显示了Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'。
完整消息是
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,我怎样才能阻止它这样做呢?
发布于 2022-05-13 09:20:44
问题是:
死蛇ppa不再适用于Ubuntu。这就是你不能安装python3.9的原因。参见这问题。您必须从源代码编译或将您的服务器升级到受支持的Ubuntu版本。
解决方案:自己构建
如果您无法升级您的系统,您可以使用碧昂夫安装任何给定的python版本,如下所述。为此,需要为python >= 3.8安装一个新版本的openssl
# 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发布于 2022-02-23 14:32:09
你可能已经安装好了
尝试运行$ python3 --version以查看您运行的python版本。如果未安装,请尝试运行$ sudo apt-get update,然后运行$ sudo apt-get install python3.9以安装python3.9
希望这能帮上忙
https://stackoverflow.com/questions/71238292
复制相似问题