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
© 版权声明
THE END
暂无评论内容