如何在命令行中从OpenSSL(pyOpenSSL)正确导入加密?

时间:2018-10-19 07:17:45

标签: cryptography pyopenssl

环境:Ubuntu 12.04.5 LTS x64,OpenSSL v1.0.2h,pyOpenSSL v16.1.0,Python v2.7.3,Eclipse Oxygen.1a(4.7.1a)。

名为“ test.py”的程序:

#/usr/bin/env python
#encoding:utf-8

from OpenSSL import crypto
print crypto.__file__

print "hello world"

该程序在Eclipse中运行,并获得以下结果。

/usr/local/lib/python2.7/site-packages/OpenSSL/crypto.pyc
hello world

尽管如此,当在命令行中运行同一程序时,仍会发生错误,并且信息如下所示。

$ python test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    from OpenSSL import crypto
  File "/usr/local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/local/lib/python2.7/site-packages/OpenSSL/rand.py", line 12, in <module>
    from OpenSSL._util import (
  File "/usr/local/lib/python2.7/site-packages/OpenSSL/_util.py", line 6, in <module>
    from cryptography.hazmat.bindings.openssl.binding import Binding
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 14, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: /usr/local/lib/python2.7/site-packages/_cffi_backend.so: undefined symbol: PyUnicodeUCS2_FromUnicode

Eclipse和命令行中的程序导入相同的“ crypto.pyc”,为什么它在Eclipse(UCS2)中失败而又在Eclipse中工作?如何在命令行中从OpenSSL正确导入加密货币?预先谢谢你!

0 个答案:

没有答案