我正在使用Python3.6,当我尝试使用pip3安装"模块"时,我面临下面提到的问题"pip配置了需要TLS/SSL的位置,但是Python中的ssl模块不可用"
请帮我解决这个问题
Ubuntu Maverick w/Python 2.7:
我无法弄清楚如何解决以下导入错误:
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named _ssl
Run Code Online (Sandbox Code Playgroud)
更新: 我重新编译了源代码.我无法弄清楚如何在下面提到的答案中添加--with-ssl选项,而是通过在/Modules/Setup.dist中编辑关于SSL的行来实现这一点.
我缺少什么?这是我第一次尝试使用 Django。Django 中内置的服务器可以在本地很好地提供该文件,但我无法让 Apache 执行相同的操作。以下是我在一个全新的、干净的 Linux 2 实例上所做的事情。
\nsudo yum update\nsudo yum install -y python3\nsudo yum install httpd-devel\nsudo yum install -y mod_wsgi\ncd /etc/httpd/modules (verify that mod_wsgi is there)\ncd /var/www/\nsudo mkdir myApp\nsudo chown ec2-user myApp\ncd myApp\nsudo pip3 install virtualenv\nvirtualenv myprojectenv\nsource myprojectenv/bin/activate\nsudo pip3 install django==2.1.1\ndjango-admin startproject myApp\ncd myApp\npython manage.py migrate\npython manage.py runserver\nwget http://127.0.0.1:8000/ (works correctly as it should and I receive test page)\npython manage.py startapp hello\ncd myApp\nvim settings.py\nRun Code Online (Sandbox Code Playgroud)\nsettings.py:编辑此部分,如下所示:
\nINSTALLED_APPS = [\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfiles',\n 'hello.apps.HelloConfig',\n]\n …Run Code Online (Sandbox Code Playgroud) 我正在尝试从容器中的源代码构建 Python 和 OpenSSL。两者似乎都构建正确,但 Python 没有成功创建_ssl模块。
我在网上找到了一些指南 ,其中提到取消 Python 中的注释和行3.X.X/Modules/Setup,并将--openssldir=/usr/local/ssl标志添加到./configureOpenSSL 的步骤中。我在我的 dockerfile 中执行这些操作。这导致在./configurePython 输出期间,我看到以下行。
checking for X509_VERIFY_PARAM_set1_host in libssl... yes
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
[91m*** WARNING: renaming "_ssl" since importing it failed: /usr/lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by build/lib.linux-x86_64-3.8/_ssl.cpython-38-x86_64-linux-gnu.so)
[0m[91m*** WARNING: renaming "_hashlib" since importing it failed: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found (required by build/lib.linux-x86_64-3.8/_hashlib.cpython-38-x86_64-linux-gnu.so)
[0m
Python build finished successfully!
Run Code Online (Sandbox Code Playgroud)
...
Following modules built successfully but were removed because they …Run Code Online (Sandbox Code Playgroud)