Python Cryptography Error无法导入名称certificate_transparency

问题描述 投票:3回答:5

试图运行一个pymodbus tcp服务器,我得到这个堆栈跟踪...在这里完全失去所以任何帮助表示赞赏。谢谢!

Traceback (most recent call last):
File "Worrking_ModbusJ1939Bridge.py", line 12, in <module>
from pymodbus.server.async import StartTcpServer
File "build/bdist.linux-armv7l/egg/pymodbus/server/async.py", line 18, in <module>
File "build/bdist.linux-armv7l/egg/pymodbus/internal/ptwisted.py", line 5, in <module>
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/manhole_ssh.py", line 14, in <module>
from twisted.conch.ssh import factory, session
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/factory.py", line 18, in <module>
from twisted.conch.ssh import (_kex, transport, userauth, connection)
File "/usr/local/lib/python2.7/dist packages/twisted/conch/ssh/transport.py", line 345, in <module>
class SSHTransportBase(protocol.Protocol):
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 469, in SSHTransportBase
supportedCiphers = _getSupportedCiphers()
File "/usr/local/lib/python2.7/dist-packages/twisted/conch/ssh/transport.py", line 335, in _getSupportedCiphers
backend=default_backend(),
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 16, in <module>
from cryptography import utils, x509
File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency
python cryptography twisted
5个回答
1
投票

我正在使用pip 7并遇到同样的问题。升级到点子9解决了它。我不确定原因。

途经:https://github.com/micheloosterhof/cowrie/issues/618


1
投票

尝试使用https://github.com/oracle/solaris-userland/构建系统更新Python 11.4的Python Cryptography时,我一直在尝试这一点。 pip的“简单”更新对我来说不是一个选择,这不是我们做事的方式。

我最终找到了解决方案:我错误地构建了包。

密码学2.1.4取决于cffi> 1.7。与我们发布的版本相比,这两个软件包都有新的可交付容量。

如果未能更新软件包清单以正确跟踪新文件,则会导致cffi和加密无法导入当前版本所依赖的符号。

[非常感谢Alex Gaynor在#cryptography-dev中让我走上正确的道路来解决这个问题]。

$ python2.7   
Python 2.7.14 (default, Jan 31 2018, 05:35:05) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.bindings._openssl import ffi, lib
>>> from cryptography.x509 import certificate_transparency
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/vendor-packages/cryptography/x509/__init__.py", line 7, in <module>
    from cryptography.x509 import certificate_transparency
ImportError: cannot import name certificate_transparency

如果您构建加密并查看它提供的内容,您会发现实际上有一个文件(在Solaris上作为/usr/lib/python-$(PYVER)/vendor-packages/cryptography/x509/certificate_transparency.py提供) - 如果该文件不在层次结构的其余部分中,那么您最终会得到这个ImportError 。


1
投票

它对我有用(paramiko的问题):

https://pypi.python.org/pypi/ctutlz/0.7.0

pip install --process-dependency-links ctutlz


0
投票

我在运行Python 2.7.8的RHEL 6.7 x86_64上有一个类似的问题,旧版本的pip(1.4.1)

这是因为我一直在安装“cp27m”版本而不是“cp27mu”版本。

使用旧的pip 1.4.1构建,它没有抱怨安装cp27m版本。

而当将pip升级到9.0.3时,它会吐出真正的错误......

(bmcs2)bash-4.1 $ pip install cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl此平台上不支持此轮。

(bmcs2)bash-4.1 $ pip install cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl cryptography-2.1.3-cp27-cp27m-manylinux1_x86_64.whl此平台上不支持此轮。

使用“cp27mu”版本解决了“ImportError:无法导入名称certificate_transparency”。当使用“cp27mu”构建时,pip 1.4.1和pip 9.0.3版本都运行良好。

cffi-1.11.5-cp27-cp27m-manylinux1_x86_64.whl与cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl

密码学-2.1.3-cp27-cp27m-manylinux1_x86_64.whl与cryptography-2.1.3-cp27-cp27mu-manylinux1_i686.whl

更多信息:https://www.python.org/dev/peps/pep-0513/#ucs-2-vs-ucs-4-builds


0
投票

我认为这更像是一个paramiko问题而不是pip。升级pip并没有在我的环境中解决这个问题我不得不将我的paramiko版本降级为没有libffi依赖的版本,这对我有用:

pip2.7 install paramiko==1.17.0

这个问题与:https://github.com/paramiko/paramiko/issues/1401有关


0
投票

尝试在AWS Lambda中运行Scrapy时,我遇到此错误,使用zip文件进行部署。

我按照https://www.perrygeo.com/running-python-with-compiled-code-on-aws-lambda.html中的说明进行操作,它基本上指示您启动Amazon Linux EC2实例,安装需求并从中构建zip。

设置完整件后,我创建的第一个包仍然给了我同样的错误,但我意识到这是因为zip文件中缺少一个隐藏文件夹.libs_cffi_backend。该文件夹包含一个.so文件,如果不存在则会导致ImportError。在强行包含它之后,它起作用了。

© www.soinside.com 2019 - 2024. All rights reserved.