我有一个与Python中的加密包有关的问题。如果可能的话,你能帮忙解决这些问题吗?(试了很多次,但找不出确切的答案)
引发此错误的python代码:
print("Salt: %s" % salt)
server_key = pyelliptic.ECC(curve="prime256v1") # ----->> Line2
print("Server_key: %s" % server_key) # ----->> Line3
server_key_id = base64.urlsafe_b64encode(server_key.get_pubkey()[1:])
http_ece.keys[server_key_id] = server_key
http_ece.labels[server_key_id] = "P-256"
encrypted = http_ece.encrypt(data, salt=salt, keyid=server_key_id,
dh=self.receiver_key, authSecret=self.auth_key) # ----->> Line8
“盐”的价值在100%的案例中得到了体现。在
如果Line3成功执行,我会看到以下由于http而导致的入口点错误_ece.加密()呼叫(Line8):
^{pr2}$(参考文件链接:https://github.com/martinthomson/encrypted-content-encoding/blob/master/python/http_ece/init.py#L128)
在要求.txt(部分):
cryptography==1.5
pyelliptic==1.5.7
pyOpenSSL==16.1.0
运行命令:sudo pip freeze --all |grep setuptools
,我得到:
setuptools==27.1.2
如果需要更多细节,请告诉我。在
这个问题似乎基本上是由于VM上安装了一些旧的/不兼容的包(与pyelliculation、Cryptography、PyOpenSSL和/或setuptools相关)。供参考:https://github.com/pyca/cryptography/issues/3149
有人能提出一个好的解决方案来彻底解决这个问题吗?在
谢谢
从项目路径/opt/projects/myproject google/myproject运行以下命令,解决了属性入口点错误问题:
(假设project virtual env路径为:/opt/projects/myproject google/venv)
命令:(from path:/opt/projects/myproject google/myproject)
运行上述命令可升级虚拟环境和虚拟环境中的setuptools版本。位于路径:/opt/projects/myproject google/venv/lib/python2.7/site-packages。要测试setuptools是否已成功升级,请尝试以下命令:
sudo virtualenv version
输出:15.0.3
echo $PYTHONPATH
输出:[空白]python -c 'import pkg_resources; print(pkg_resources.__file__)'
输出:~/.local/lib/python2.7/site-packages/pkg_resources/__init__.pyc
python -c 'import sys; print(sys.path)'
输出:['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '~/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/opt/projects/myproject-google/myproject', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat']
ls /opt/projects/myproject-google/venv/lib/python2.7/site-packages
输出:easy_install.py pip pkg_resources setuptools-27.2.0.dist-info wheel-0.30.0a0.dist-info easy_install.pyc pip-8.1.2.dist-info setuptools wheel
<cryptography.hazmat.backends.multibackend.MultiBackend object at 0x7ff83a838d50>
/opt/projects/myproject-google/venv/bin/python -c 'from cryptography.hazmat.backends import default_backend; print(default_backend())'
输出Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named cryptography.hazmat.backends
/opt/projects/myproject-google/venv/bin/python -c "import pkg_resources; print(pkg_resources.__file__)"
输出:/opt/projects/myproject-google/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.pyc
参考链接:https://github.com/pyca/cryptography/issues/3149
这些步骤通过加密软件包和setuptools的更新版本完全解决了属性入口点问题。在
更新截至2016年9月15日,加密团队再次添加了支持旧软件包的解决方案。 (参考链接:https://github.com/pyca/cryptography/issues/3150)
在c66303382中引用的issue有这样的回溯(您从未给出回溯,所以我必须假设您的结果是相同的):
触发错误的The full line如下所示:
^{pr2}$在repository中搜索} 中发现{}被添加到
EntryPoint
定义,然后在blaming ^{setuptools v11.3
的commit 92a553d3adeb431cdf92b136ac9ccc3f2ef98bf1(2015-01-05)。在因此,如果使用旧版本,您将看到此错误。在
相关问题 更多 >
编程相关推荐