Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian 9 Stretch Python 3.4.4 BUILD FAILED #945

Closed
Yoshi325 opened this issue Jun 30, 2017 · 23 comments
Closed

Debian 9 Stretch Python 3.4.4 BUILD FAILED #945

Yoshi325 opened this issue Jun 30, 2017 · 23 comments
Labels
area: build bugs or improvements with `pyenv install` impl: cpython os: Linux

Comments

@Yoshi325
Copy link

I am having trouble getting Python 3.4.4 to install on Debian 9 Stretch. Here is what I have tried:

$ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install -v 3.4.4

[...]

if test "x" != "x" ; then \
	rm -f /home/yoshi325/.pyenv/versions/3.4.4/bin/python3-32; \
	(cd /home/yoshi325/.pyenv/versions/3.4.4/bin; ln -s python3.4-32 python3-32) \
fi
rm -f /home/yoshi325/.pyenv/versions/3.4.4/share/man/man1/python3.1
(cd /home/yoshi325/.pyenv/versions/3.4.4/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--upgrade" ;; \
		install|*) ensurepip="" ;; \
	esac; \
	LD_LIBRARY_PATH=/tmp/python-build.20170630131548.35254/Python-3.4.4 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
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 (Debian 9.0 using python-build 1.1.1-5-g7467eec)

Inspect or clean up the working tree at /tmp/python-build.20170630131548.35254
Results logged to /tmp/python-build.20170630131548.35254.log

Last 10 log lines:
(cd /home/yoshi325/.pyenv/versions/3.4.4/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--upgrade" ;; \
		install|*) ensurepip="" ;; \
	esac; \
	LD_LIBRARY_PATH=/tmp/python-build.20170630131548.35254/Python-3.4.4 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
$ sudo dpkg --list | grep ssl
ii  libssl-dev:amd64              1.1.0f-3                       amd64        Secure Sockets Layer toolkit - development files
ii  libssl-doc                    1.1.0f-3                       all          Secure Sockets Layer toolkit - development documentation
ii  libssl1.0.2:amd64             1.0.2l-2                       amd64        Secure Sockets Layer toolkit - shared libraries
ii  libssl1.1:amd64               1.1.0f-3                       amd64        Secure Sockets Layer toolkit - shared libraries
ii  openssl                       1.1.0f-3                       amd64        Secure Sockets Layer toolkit - cryptographic utility
$ CFLAGS="-I/usr/include/x86_64-linux-gnu/" LDFLAGS="-L/usr/lib/x86_64-linux-gnu/" PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.4

Downloading Python-3.4.4.tar.xz...
-> https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tar.xz
Installing Python-3.4.4...
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 (Debian 9.0 using python-build 1.1.1-5-g7467eec)

Inspect or clean up the working tree at /tmp/python-build.20170630132737.63142
Results logged to /tmp/python-build.20170630132737.63142.log

Last 10 log lines:
(cd /home/yoshi325/.pyenv/versions/3.4.4/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
	case upgrade in \
		upgrade) ensurepip="--upgrade" ;; \
		install|*) ensurepip="" ;; \
	esac; \
	LD_LIBRARY_PATH=/tmp/python-build.20170630132737.63142/Python-3.4.4 ./python -E -m ensurepip \
		$ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS
@JayH5
Copy link
Contributor

JayH5 commented Jul 24, 2017

This is probably due to Debian 9 using OpenSSL 1.1.0. OpenSSL 1.1.0 support in the ssl module was only added to Python 2.7.13, 3.5.3 and 3.6.0: https://bugs.python.org/issue26470

@yyuu
Copy link
Contributor

yyuu commented Jul 25, 2017

Hmm. Actually we're applying some patches to ssl module of some older releases. We may be able to do similar for the issue.

https://github.com/pyenv/pyenv/blob/7dae19765cf5d592a718978967a4181c33b79846/plugins/python-build/share/python-build/patches/2.7.9/Python-2.7.9/010_ssl_no_ssl3.patch

@simingy
Copy link

simingy commented Aug 14, 2017

+1... doesn't work with Python 3.4.7 either

@rhocairn
Copy link

rhocairn commented Mar 30, 2018

Has there been any movement on this? I'm trying to create a Docker image for running PySpark tests that extends from openjdk:8 (which extends from buildpack-deps:stretch-scm which is basically just Debian Stretch) and it would be really nice to be able to run tests using python 3.4.

@jsoref
Copy link

jsoref commented May 17, 2018

For reference this impacts Ubuntu bionic as well (since that's the first Ubuntu to get 1.1 which flowed from Debian stretch).

@ipatch
Copy link

ipatch commented May 19, 2018

there's two versions of openssl library and headers supplied by apt-get.

@mgeens
Copy link

mgeens commented Jul 9, 2018

Unfortunately in bionic installing the 1.0 dev version uninstalls the 1.1 dev version, and everything that depends on it, including npm / nodejs.

@JustAnotherArchivist
Copy link

I succeeded in building 3.4.8 on Debian Stretch while keeping the 1.1 headers. This is really a dirty workaround though, not a proper fix to this issue.

As others have mentioned before, installing the 1.0 headers through apt doesn't work (unless you can live without the 1.1 headers). The two -dev packages conflict with each other since there is no concept like sonames for header files.

My workaround is simply to install the headers in a separate directory somewhere in my home directory. That's not a true installation, and most notably, package upgrades will have to be done manually. Download the libssl1.0-dev .deb (e.g. using apt-get download libssl1.0-dev) and extract it, then extract the contents of data.tar.gz somewhere. I put it in ~/libssl1.0-dev, but ~/.local would probably be a better place for it (in which case you should consider using GNU Stow if you want to install other things there sometime). The location doesn't really matter much except that you need it in the later commands.

> mkdir ~/libssl1.0-dev
> cd ~/libssl1.0-dev
> apt-get download libssl1.0-dev
> ar x libssl1.0-dev_1.0.2l-2+deb9u3_amd64.deb data.tar.xz
> tar -xf data.tar.xz --strip-components=2
> rm data.tar.xz

The libssl1.0-dev package contains two symlinks for libssl.so and libcrypto.so, and these don't point anywhere in that directory. We could "install" libssl1.0 into the same directory to work around this, but I really didn't want to do that, so I just set up two symlinks (the last path segment may be different depending on your computer architecture):

> ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 ~/libssl1.0-dev/lib/x86_64-linux-gnu
> ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 ~/libssl1.0-dev/lib/x86_64-linux-gnu

Then, we need to tell Python about these files. This means setting a bunch of environment variables:

 > CFLAGS="-I${HOME}/libssl1.0-dev/include -I${HOME}/libssl1.0-dev/include/x86_64-linux-gnu" LDFLAGS="-L${HOME}/libssl1.0-dev/lib/x86_64-linux-gnu" pyenv install 3.4.8

This will let it compile and install. There is no need to set an LD_LIBRARY_PATH or other environment variable to run Python since OpenSSL is installed in /usr/lib. You can remove ~/libssl1.0-dev after installation if you want; the header files are only needed for compilation.

> pyenv shell 3.4.8
> python -V
Python 3.4.8
> python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
OpenSSL 1.0.2l  25 May 2017

shushen added a commit to shushen/tox that referenced this issue Sep 8, 2018
shushen added a commit to shushen/tox that referenced this issue Sep 8, 2018
* Fix travis configuration

* Install Python versions in sequence 

When increased number of versions executed in parallel, the 
console is quiet for too long and causes travis-ci and 
hub.docker.com to timeout.

* Adding missing dependencies

* Drop 3.4.x

Due to pyenv/pyenv#945

* Drop 3.4

* Drop 3.4
@Benestar
Copy link

Benestar commented Nov 9, 2018

@JustAnotherArchivist do you think this workaround can somehow be included in the pyenv install script? I guess we could automatically download the header files in a temporary directory, compile the specified python version and afterwards clean the mess up.

@JustAnotherArchivist
Copy link

@Benestar, I think it could probably be done but might be quite tricky.
You need the headers matching the installed OpenSSL version. Now, it might be possible to get away with just using the original headers from upstream OpenSSL, but I'm not sure if that would work in all cases. So you'd probably need distro-specific code, possibly also with variations for different versions of the distribution, and that gets very messy very quickly and would likely break on non-standard setups (e.g. self-compiled OpenSSL).

@chrahunt
Copy link
Member

chrahunt commented Feb 4, 2019

With linuxbrew this is now a matter of brew install openssl and following the directions here for CFLAGS/LDFLAGS.

@chrahunt chrahunt added area: build bugs or improvements with `pyenv install` impl: cpython os: Linux labels Apr 18, 2019
@chrahunt
Copy link
Member

Closing, as straightforward workarounds are available.

@and-semakin
Copy link

I managed to install Python 3.4.10 on Fedora 30 (has OpenSSL 1.1+ by default) using following instructions:

  1. Temporary remove openssl-devel if it is installed as it will conflict with older version:

     $ sudo dnf remove openssl-devel
    
  2. Install compat OpenSSL 1.0 packages:

     $ sudo dnf install compat-openssl10 compat-openssl10-devel
    
  3. Build Python 3.4.10 (I use asdf but it seems to use pyenv under the hood so it should work with pyenv as well):

     $ asdf install python 3.4.10
    
  4. Remove compat library and install modern instead:

     $ sudo dnf remove compat-openssl10-devel
     $ sudo dnf install openssl-devel
    

@tillstuder
Copy link

I could fix the issue by appending deb http://security.ubuntu.com/ubuntu bionic-security main to my /etc/apt/sources.list file.
After that run sudo apt update && apt-cache policy libssl1.0-dev
And then sudo apt-get install libssl1.0-dev

@keevee09
Copy link

@tillstud 's solution worked for me on Ubuntu 18.04 although I had to install libssl1.0-dev
Some update/upgrade must have removed it. I'm not sure why or when.

@EmilStenstrom
Copy link

@tillstud Still works on Ubuntu 20 (focal) 🥳

@Staubgeborener
Copy link

Works on Debian Buster with sudo apt-get install zlib1g-dev

@quanengineering
Copy link

quanengineering commented Jun 8, 2021

Neither @JustAnotherArchivist or @tillstud's solution does not work on Ubuntu 21.

@FreemanPancake
Copy link

I could fix the issue by appending deb http://security.ubuntu.com/ubuntu bionic-security main to my /etc/apt/sources.list file. After that run sudo apt update && apt-cache policy libssl1.0-dev And then sudo apt-get install libssl1.0-dev

Thank you @tillstud, This solution works on WSL(Ubuntu 20)

@dieterplex
Copy link

On newer Ubuntu release apt-get download libssl1.0-dev won't work, unless editing sources.list to include bionic packages.
Alternatively, directly download from package pool http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/ is possible.

curl -O http://security.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0-dev_1.0.2n-1ubuntu5.8_amd64.deb

and manually extract, compile and install with it.

@kmecpp
Copy link

kmecpp commented Apr 26, 2022

These solutions don't work without permission to install the SSL packages, and not having these permissions was whole the reason I was using PyEnv in the first place to install Python

@native-api
Copy link
Member

These solutions don't work without permission to install the SSL packages, and not having these permissions was whole the reason I was using PyEnv in the first place to install Python

@kmecpp you can build OpenSSL from source and point Python-build to it with envvars.

@brian-smith-tcril
Copy link

With Debian 12 (bookworm) 1.1 is no longer available, using brew I was able to get everything working

LDFLAGS="-Wl,-rpath,$(brew --prefix openssl@1.1)/lib" \
CONFIGURE_OPTS="-with-openssl=$(brew --prefix openssl@1.1)" \
pyenv install 3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build bugs or improvements with `pyenv install` impl: cpython os: Linux
Projects
None yet
Development

No branches or pull requests