LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   Build python 3.11 from source on centos 7 (https://www.linuxquestions.org/questions/centos-111/build-python-3-11-from-source-on-centos-7-a-4175719297/)

Shaggy1 11-30-2022 09:21 AM

Build python 3.11 from source on centos 7
 
Hi

System Info:
Code:

$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)

$ openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017


I am attempting to build python 3.11 on a centos 7 system.
When I try to configure using this command:
Code:

$ ./configure --prefix=/local/usr/local/python3 --enable-shared --with-ensurepip=install --enable-optimizations
and then try to make I get the following error:
Code:

Python runtime state: initialized
Traceback (most recent call last):
  File "/local/usr/local/src/python/Python-3.11.0/Lib/site.py", line 73, in <module>
    import os
  File "/local/usr/local/src/python/Python-3.11.0/Lib/os.py", line 29, in <module>
    from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
make[1]: *** [Python/frozen_modules/abc.h] Error 1
make[1]: Leaving directory `/local/usr/local/src/python/Python-3.11.0'
make: *** [profile-opt] Error 2

I think I am hitting the issue described here:
https://github.com/python/cpython/issues/94825

Which suggests I need a more up to date gcc version.
Does anyone know which gcc version works for building this with optimization ? Or know where I can find out ?

When it does build successfully (as mentioned in the link if I repeat it enough it eventually goes through and also if I turn off optimizations) I get the following message at the end:
Quote:

The necessary bits to build these optional modules were not found:
_hashlib _ssl _tkinter
I do need the _ssl module - does anyone know how I can find out what I need to allow it to build ? Possibly I need a newer openssl version ?

Ooops sorry I missed this message at the end:
Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

That explains the ssl issue. Anyone know if it is possible to install openssl 1.1.1 on centos 7 from a repository ? Or do I have to build a local version ?

pan64 12-01-2022 12:23 AM

You need to use gcc 11 or something similar (probably gcc 7 would be ok too). 4.8.5 is at about (or more than) 10 years old and does not support newer c++ standards.

boughtonp 12-01-2022 07:06 AM


 
The current version of CentOS 7 is 7.9.2009 - why are you still on 7.6 yet trying to build Python 3.11 - which was released less than six weeks ago?


Shaggy1 12-01-2022 08:18 AM

> The current version of CentOS 7 is 7.9.2009 - why are you still on 7.6 ...
Unfortunately my hands are tied on this, it's a standard install for our lab machines, however

> ... yet trying to build Python 3.11
Indeed it does not need to be 3.11, I wound back to 3.8 and that build fine

Thank you for your help

Just in a general sense do you know if there is a way of getting hold of what version of tools is required for each version ?

boughtonp 12-01-2022 08:43 AM

Quote:

Originally Posted by Shaggy1 (Post 6395496)
Indeed it does not need to be 3.11, I wound back to 3.8 and that build fine

That's good then - Python 3.8 is supported until October 2024, which is later than the EOL for CentOS - so most software should run on it until then.

(You may want to check whoever controls the OS of your lab machine is aware of AlmaLinux and Rocky Linux.)


Quote:

Just in a general sense do you know if there is a way of getting hold of what version of tools is required for each version ?
I've never built Python from source but, speaking generally, when it's not part of core repos there's usually something good enough in EPEL.

I think there was one instance when I needed a specific version of either ImageMagick or GraphicsMagick and had to build it from source, but I can't remember the details.



All times are GMT -5. The time now is 02:31 AM.