Moving to Ubuntu 22 with a fresh install (I have Ubuntu 20 in another partition) and the last piece I need to use it for working it to have pyenv running fine.
When trying to pyenv install x.xx.x
it fails with this error:
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
I "tried to try" what the official docs proposes:
I said "tried to try" because I don't understand what I have to do. They give these commands:
CPPFLAGS="-I<openssl install prefix>/include" \
LDFLAGS="-L<openssl install prefix>/lib" \
pyenv install -v <python version>
But I don't know what the "openssl install prefix" means. I assumed it's the openssl installation dir, so I did:
openssl version -d
OPENSSLDIR: "/home/linuxbrew/.linuxbrew/etc/[email protected]"
Even though I see that in this folder there arent' any include
or lib
subfolders, I tried it anyway by doing this:
CPPFLAGS="-I/home/linuxbrew/.linuxbrew/etc/[email protected]/include" \
LDFLAGS="-L/home/linuxbrew/.linuxbrew/etc/[email protected]/lib" \
pyenv install -v 3.10.0
Which ended up with the same error message.
Gotta say, I tried a lot of other stuff that I found in other places and nothing worked, but for the sake of simplicity I'm sticking with the official indications.
If you faced the same problem and the solution came from somewhere else than these commands, please share!
Many thanks :)
<openssl install prefix>
just refers to the base path or base folder, just that Homebrew decided to invent a new name because... well, some very important reason I guess.
This part gets solved by just replacing <openssl install prefix>
by $(brew --prefix openssl)
.
See my own answer to the question below to see how it worked for me, but judging for all the different solutions that I've been seeing and trying, every case might need a different solution. Good luck!
Had same trouble, for me it worked after ran following command(check https://github.com/pyenv/pyenv/wiki#suggested-build-environment).
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Could install without additional flags.
pyenv install -v 3.9.13
About the doubt on what <openssl install prefix>
is, I'll edit the question clarifying it.
About how to make pyenv install versions successfully, after trying everything I found about the topic that's the only thing that worked for me:
LDFLAGS="-Wl,-rpath,$(brew --prefix openssl)/lib" \
CPPFLAGS="-I$(brew --prefix openssl)/include" \
CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)" \
pyenv install -v 3.9.5
For every new version, I use this command and it works.
Note that:
pyenv install xx.xx
, I always have to use the full command no matter what.Not happy at all with all this mess but at least now I can use 22.04 for working.
Edit: I tried Jakob's suggestion to add it to .bashrc, like this:
export LDFLAGS="-Wl,-rpath,$(brew --prefix openssl)/lib"
export CPPFLAGS="-I$(brew --prefix openssl)/include"
export CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)"
Then I did $SHELL
to reload it, and then pyenv install xx.xx.xx
worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With