在 CentOS 7 中安装带有 SSL 模块的 Python 3.12.2 时出错

问题描述 投票:0回答:1

我一直在尝试在 CentOS v7.9.2009 中安装带有 SSL 模块的 Python 3.12.2,但最后出现错误。 我已经遵循了这些步骤,但最后我总是遇到相同的错误:

[root@server Python-3.12.2]# make altinstall
./_bootstrap_python ./Programs/_freeze_module.py abc ./Lib/abc.py Python/frozen_modules/abc.h
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "/usr/src/Python-3.12.2/Lib/site.py", line 73, in <module>
    import os
  File "/usr/src/Python-3.12.2/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: *** [Python/frozen_modules/abc.h] Error 1

在此之前我在“test_embed”中也遇到了失败:

0:00:22 load avg: 0.95 [16/44] test_embed
test test_embed failed
0:00:30 load avg: 0.95 [17/44] test_float -- test_embed failed (2 errors)

然后,当我运行 Python 时,我得到以下输出:

[root@server Python-3.12.2]# python3.12
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3.12'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/usr/local/lib/python3.12'
  sys._base_executable = '/usr/local/bin/python3.12'
  sys.base_prefix = '/usr/local'
  sys.base_exec_prefix = '/usr/local'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/local/bin/python3.12'
  sys.prefix = '/usr/local'
  sys.exec_prefix = '/usr/local'
  sys.path = [
    '/usr/local/lib/python312.zip',
    '/usr/local/lib/python3.12',
    '/usr/local/lib/python3.12/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fb3369f7740 (most recent call first):
  <no Python frame>

当我不使用 SSL 时,Python 安装没有任何问题。

以下这个其他答案安装得很好,但我想要最新版本,因为我的项目是在 3.12.2 版本中制作的。

我应该怎么做才能解决这个问题?

python python-3.x centos centos7
1个回答
0
投票
yum install openssl11 openssl11-devel
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
./configure --enable-optimizations
make -j$(nproc)
make altinstall 

我已经在 CentOS 7.9.2009 上成功安装了 Python 3.12.3

© www.soinside.com 2019 - 2024. All rights reserved.