简体   繁体   中英

Python 2.7.12 on Ubuntu 20.04 in PyEnv

I have some legacy websites that run on Python 2.7.12 and have just updated my dev machine to Ubuntu 20.04.

I am trying to get PyEnv to install Python 2.7.12, but it seems that this depends on libssl1.0-dev which has been dropped in Ubuntu 20.04.

I get error:

Installing Python-2.7.12...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Ubuntu 20.04 using python-build 20180424)

Following advice here I run:

sudo apt-get remove libssl-dev
sudo apt-get update
sudo apt-get install libssl1.0-dev

I get error:

E: Package 'libssl1.0-dev' has no installation candidate

Is there any way of doing this? If so then how please?

Thank you.

As Klaus mentioned you could use docker image for p ython 2.7 , but ssl library is very crucial, so it's weird that it has no installation candidate. The package libssl-dev for focal is listed here

You can install libssl1.0-dev from previous Ubuntu 18.04 release:

wget -P /tmp/ http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0-dev_1.0.2n-1ubuntu5.5_amd64.deb
wget -P /tmp/ http://ftp.osuosl.org/pub/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5.5_amd64.deb
apt install /tmp/libssl1.0.0_1.0.2n-1ubuntu5.5_amd64.deb
apt install /tmp/libssl1.0-dev_1.0.2n-1ubuntu5.5_amd64.deb

It works, butthis is not recommend way. Because libssl1.0 package will not receive security updates in the future. Maybe python 2.7?17 is OK for you: You can install it via apt:

apt install python2

I couldn't see a way of getting PyEnv to work with such an old version of Python, so opted for using Docker as suggested by Klaus and Rafal. Thank you.

For others struggling with this, here is a handy overview of the process .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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