Install Python 3.7+ on CentOS 7

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

  1. Install build tools sudo yum install gcc openssl-devel bzip2-devel libffi-devel
  2. Download the source from https://www.python.org/downloads/source/
  3. Extract the source
  4. run ./configure --enable-optimizations --enable-shared
  5. 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

原文链接:Install Python 3.7+ on CentOS 7

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容