草庐IT

Python 3.7 无法连接到 HTTPS URL,因为 SSL 模块不可用

coder 2023-08-19 原文

我正在运行 centos 6.10 的专用服务器上安装 Python 3.7 在跳过一些障碍尝试执行此操作后,我遇到了另一个错误。使用 Python 3.7 尝试保持最新状态,pip 安装出现 SSL 问题是一个相当普遍的问题。我得出的结论是,解决此问题的最佳方法是获取正确版本的 OpenSSL。所以我这样做了,并编辑了我的 python modules/Setup.dist 文件,重新配置它,重新运行 make altinstall,虽然一切看起来都很好。由于某些原因,我之前运行这个python的命令Python3.7突然变成了无法识别的命令,而在Python3.7目录下有一个文件夹python 现在执行时(编辑环境路径后打开 Python3.7。之前情况并非如此,它只是 Python3.7 有人知道这里会发生什么吗?

此外,我对整个 SSL 的事情都快无能为力了,我已经阅读了所有关于 SSL 的文章。这是我最近执行的一些命令的列表:

#Unpacked Python3.7 into /usr/src directory
./configure --enable-optimizations --enable-loadable-sqlite-extensions
make altinstall

#installation failed from no '_ctypes' module

yum install libffi-devel

#repeat configure above
#yaaay python
#Successfully installed pip-10.0.1 setuptools-39.0.1 was the final message of the installation

Python3.7 -m venv /my/project/directory/ENV
pip install {library}

#this is where my issues began with SSL

日志:

(ENV) [root@s1.1.1.1 ProjectDirectory]# pip3 install twisted
pip is configured with locations that require TLS/SSL, however, the SSL module in Python is not available.
Collecting twisted
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/
  Could not fetch URL https://pypi.org/simple/twisted/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/twisted/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
  Could not find a version that satisfies the requirement twisted (from versions: )
No matching distribution found for twisted
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSLmodule is not available.")) - skipping

所以我觉得还不错。不用担心。最新版本的 Python 甚至无法立即获得 pip3。精彩的。好吧,我开始像我们一样搜索谷歌并得出结论,每个人都只是再次重新配置他们的 python 并且它神奇地起作用了。不知道为什么,但是没关系。我很喜欢它。我找到了这篇文章:

https://techglimpse.com/install-python-openssl-support-tutorial/

想想还不错。如果我可以获得 python3.7 SSL,那么它应该可以让 pip3 正常工作吗?错误的。不幸的是,如果我以上面提到的新奇怪方式启动 Python3.7,并键入 import ssl,我会收到此错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/src/Python-3.7.0/Lib/ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'

谁能给我一些帮助?我有点迷失在海洋中,而且我不会游泳......任何东西都会很棒,但我是这个服务器管理员的菜鸟所以越简单越好 :) 谢谢你提前。

编辑: 顺便说一下

yum install openssl

yum install openssl-devel

两者都会导致“已安装”标志...所以我认为这不是另一种解决方案。但是,当我手动安装时,我使用了 1.1.1 版,因为我知道 3.7 出于某种原因放弃了对几个不同版本的 OpenSSL 的支持。我认为已经安装了 yum 的是 1.0.2。不知道有没有centos 6.10平台的容量,不过版本限制。

最佳答案

我在 ma​​c OS 上遇到了类似的问题,我无法安装任何东西甚至无法升级 pip由于 SSL 问题,来自虚拟环境。

对我有用的是在虚拟环境中执行以下操作

  1. sudo chown -R ${whoami} /usr/local/Cellar其次是

  2. brew install openssl

什么是${whoami}在第一个命令中?

这是一个占位符;当你运行命令时你应该放在那里的是你当前的实际用户。

如果您不知道您的用户,请在命令行中输入

whoami

输出是你的用户。所以如果你输入它并得到 johnsmith作为输出,当您运行第一个命令时,您会将“${whoami}”替换为“johnsmith”,如下所示:

sudo chown -R johnsmith /usr/local/Cellar

关于Python 3.7 无法连接到 HTTPS URL,因为 SSL 模块不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52566503/

有关Python 3.7 无法连接到 HTTPS URL,因为 SSL 模块不可用的更多相关文章

  1. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  2. ruby-on-rails - Ruby net/ldap 模块中的内存泄漏 - 2

    作为我的Rails应用程序的一部分,我编写了一个小导入程序,它从我们的LDAP系统中吸取数据并将其塞入一个用户表中。不幸的是,与LDAP相关的代码在遍历我们的32K用户时泄漏了大量内存,我一直无法弄清楚如何解决这个问题。这个问题似乎在某种程度上与LDAP库有关,因为当我删除对LDAP内容的调用时,内存使用情况会很好地稳定下来。此外,不断增加的对象是Net::BER::BerIdentifiedString和Net::BER::BerIdentifiedArray,它们都是LDAP库的一部分。当我运行导入时,内存使用量最终达到超过1GB的峰值。如果问题存在,我需要找到一些方法来更正我的代

  3. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  4. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  5. ruby-on-rails - 无法使用 Rails 3.2 创建插件? - 2

    我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby​​1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在

  6. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  7. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  8. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  9. ruby - 续集在添加关联时访问many_to_many连接表 - 2

    我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以

  10. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

随机推荐