安装带有 python 问题的加密

Installing crypto with python issue

我有一些 python 使用加密的代码

from Crypto.Random.random import getrandbits
from Crypto import Random
from Crypto.Random import random
from Crypto.PublicKey import ElGamal
import socket
import time

当我 运行 文件时出现错误 Traceback (most recent call last): File "./alice_solution.py", line 6, in <module> from Crypto.Random.random import getrandbits ModuleNotFoundError: No module named 'Crypto'

当我尝试安装模块时 pip install Crypto 我得到这个错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting Crypto
  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/crypto/
  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/crypto/
  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/crypto/
  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/crypto/
  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/crypto/
  Could not fetch URL https://pypi.org/simple/crypto/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/crypto/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is notavailable.")) - skipping
  Could not find a version that satisfies the requirement Crypto (from versions: )
No matching distribution found for Crypto
You are using pip version 18.0, however version 20.3b1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

请帮忙...我尝试重新研究这个问题,但没有发现任何有效的方法

ssl模块是Python本身的标准库模块。 pip 要求它能够通过 TLS 获取资源。如果你自己编译这个 Python 你需要确保你有正确的依赖项(例如 openssl 开发头文件等)。如果没有,请检查您平台的包管理器,看看是否有额外的包可以提供此功能。