This was my first time to install a recent version of Python on a CentOS. I always use Ubuntu and It is pretty easy using deadlysnakes PPA. so the only way was to compile the source code from python.org website.
The how-to is on the internet but I'm writing this as I did compilation serveral times as some options weren't set properaly. so let's go
- Install build tools
sudo yum install gcc openssl-devel bzip2-devel libffi-devel
- Download the source from
https://www.python.org/downloads/source/
- Extract the source
- run
./configure --enable-optimizations --enable-shared
- run
make altinstall
Notes:
-
libffi
is crucial, so don't forget it. -
--enable-shared
is required if you will compile any library with C Extension. - pip will be installed by default.
- If you get
/usr/local/bin/python3.7: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
, then do the following -
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
or sudo ldconfig /usr/local/lib
Top comments (7)
This one I found is similar but uses
sudo make altinstall
computingforgeeks.com/how-to-insta...
And unzipping on the command line
I started using pyenv to install user-level python versions.
I don't know what repository it points to but you might get something more recent with that then yum. And then you can use pyenv to install new versions of python when they come out
github.com/pyenv/pyenv
Maybe there is an easier way to install but I came across this
gist.github.com/ysaotome/7956676
Some more context for other readers. Python is available in the standard repos for Ubuntu and presumably CentOS for us with apt and yum. They are focused on stability so will be behind the latest.
but if you want the most recent you have to add another repository like the deadsnakes one for ubuntu.
Or download the source and compile Python yourself (I did this once and it took a long time and gave a lot of errors so would not recommend).
Is there no deadsnakes alternative for CentOS?
I tried but didn't find any.
I found ius.io as a community list of packages but it only goes up to 3.6 :/
repo.ius.io/7/src/packages/p/
Several not serveral
Thanks