How to resolve openssl not found error while installing new Python version with Pyenv on M1 Mac OS Ventura 13.1?

huangapple go评论67阅读模式
英文:

How to resolve openssl not found error while installing new Python version with Pyenv on M1 Mac OS Ventura 13.1?

问题

系统使用的是MacOS Ventura 13.1上的M1处理器。在使用pyenv安装新版本时,出现了关于系统上找不到openssl的错误。openssl已经安装,版本号是LibreSSL 3.3.6

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'readline'
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/divyesh.parmar@postman.com/.pyenv/versions/3.10.6/lib/python3.10/ssl.py", line 99, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

我已经尝试了这个帖子中提到的方法,但似乎都没有效果。如何解决这个问题?

英文:

The system is M1 processor on MacOS Ventura 13.1. While installing a new version with pyenv, it throws following error regarding openssl not found on the system. openssl is already installed with the version number LibreSSL 3.3.6

Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
ModuleNotFoundError: No module named &#39;readline&#39;
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/Users/divyesh.parmar@postman.com/.pyenv/versions/3.10.6/lib/python3.10/ssl.py&quot;, line 99, in &lt;module&gt;
    import _ssl             # if we can&#39;t import it, let the error propagate
ModuleNotFoundError: No module named &#39;_ssl&#39;
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

I've mostly tried approaches mentioned on this thread, but none of that seems to lead to anywhere. How to resolve this?

答案1

得分: 1

在查看了Pyenv项目的多个Github主题后,其中一种最简单的方法奏效。

# 提供一个错误的openssl版本,强制下载并在构建过程中链接正确的openssl版本
export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0

设置了这个之后,运行安装任何版本的命令时,将自动下载和链接所需版本的openssl

参考链接:https://github.com/pyenv/pyenv/issues/1768#issuecomment-1423144852

英文:

After looking at several Github threads on Pyenv project, one of the simplest method worked like a charm.

# Providing an incorrect openssl version forces a proper openssl version to be downloaded and linked during the build
export PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl@1.0

After setting this, upon running the command to install any version, it will automatically download and link the required version of openssl

Reference : https://github.com/pyenv/pyenv/issues/1768#issuecomment-1423144852

答案2

得分: 0

你可以使用更高版本的openssl,方法如下:

export CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl)"
英文:

You can use a higher version of openssl with :

export CONFIGURE_OPTS=&quot;--with-openssl=$(brew --prefix openssl)&quot;

huangapple
  • 本文由 发表于 2023年2月9日 03:13:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390666.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定