使用python问题安装加密货币

时间:2020-11-07 23:18:14

标签: python cryptography

我有一些使用密码的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.

请帮助...我尝试解决此问题,但没有发现任何有效的方法

1 个答案:

答案 0 :(得分:0)

ssl模块是Python本身的标准库模块。 pip要求它能够通过TLS获取资源。如果您自己编译此Python,则需要确保您具有正确的依赖项(例如,openssl开发标头等)。如果没有,请与平台的软件包管理器联系,以查看是否有其他软件包可以安装以提供此功能。