Fedora 26 中 Python M2Crypto 安装失败

标签 python m2crypto fedora-26

我在我的 PC 上运行 Fedora 26,python 版本是 2.7。我已经安装了

openssl-devel

包。 现在我正在尝试安装

M2Crypto==0.25.1

使用命令在python虚拟环境中进行打包

pip install M2Crypto==0.25.1

。安装总是失败并显示以下日志语句。

Collecting M2Crypto==0.25.1
  Using cached M2Crypto-0.25.1.tar.gz
Requirement already satisfied: typing in ./site-packages (from M2Crypto==0.25.1)
Building wheels for collected packages: M2Crypto
  Running setup.py bdist_wheel for M2Crypto ... error
  Complete output from command /home/udara/Projects/Dev/moota/ENV/new_env/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-NIhR7v/M2Crypto/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmptqERYXpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  copying M2Crypto/util.py -> build/lib.linux-x86_64-2.7/M2Crypto
  -----
  -----
  copying M2Crypto/PGP/PublicKey.py -> build/lib.linux-x86_64-2.7/M2Crypto/PGP
  running build_ext
  building 'M2Crypto.__m2crypto' extension
  swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
  swig -python -D__x86_64__ -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -builtin -outdir build/lib.linux-x86_64-2.7/M2Crypto -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
  /usr/include/sys/cdefs.h:175: Warning 305: Bad constant value (ignored).
  /usr/include/bits/wchar.h:38: Warning 490: Fragment 'SWIG_From_wchar_t' not found.
  /usr/include/stdint.h:274: Warning 490: Fragment 'SWIG_From_wchar_t' not found.
  SWIG/_bio.i:64: Warning 454: Setting a pointer/reference variable may leak memory.
  -----
  -----
  SWIG/_engine.i:168: Warning 454: Setting a pointer/reference variable may leak memory.
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/SWIG
  gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -I/usr/include -I/usr/include/openssl -I/tmp/pip-build-NIhR7v/M2Crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-x86_64-2.7/SWIG/_m2crypto_wrap.o -DTHREADING
  SWIG/_m2crypto_wrap.c:4185:35: error: ‘CRYPTO_NUM_LOCKS’ undeclared here (not in a function); did you mean ‘CRYPTO_UNLOCK’?
   static PyThread_type_lock lock_cs[CRYPTO_NUM_LOCKS];
                                     ^~~~~~~~~~~~~~~~
                                     CRYPTO_UNLOCK
  SWIG/_m2crypto_wrap.c: In function ‘lib_init’:
  SWIG/_m2crypto_wrap.c:4590:5: warning: implicit declaration of function ‘SSLeay_add_all_algorithms’; did you mean ‘SSLeay_add_ssl_algorithms’? [-Wimplicit-function-declaration]
       SSLeay_add_all_algorithms();
       ^~~~~~~~~~~~~~~~~~~~~~~~~
       SSLeay_add_ssl_algorithms
  SWIG/_m2crypto_wrap.c: In function ‘bn_rand’:
  SWIG/_m2crypto_wrap.c:5029:12: error: storage size of ‘rnd’ isn’t known
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c:5033:5: warning: implicit declaration of function ‘BN_init’; did you mean ‘bio_init’? [-Wimplicit-function-declaration]
       BN_init(&rnd);
       ^~~~~~~
       bio_init
  SWIG/_m2crypto_wrap.c:5029:12: warning: unused variable ‘rnd’ [-Wunused-variable]
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c: In function ‘bn_rand_range’:
  SWIG/_m2crypto_wrap.c:5058:12: error: storage size of ‘rnd’ isn’t known
       BIGNUM rnd;
              ^~~
  SWIG/_m2crypto_wrap.c:5058:12: warning: unused variable ‘rnd’ [-Wunused-variable]
  SWIG/_m2crypto_wrap.c: In function ‘rand_pseudo_bytes’:
  SWIG/_m2crypto_wrap.c:5209:5: warning: ‘RAND_pseudo_bytes’ is deprecated [-Wdeprecated-declarations]
       ret = RAND_pseudo_bytes(blob, n);
       ^~~
  In file included from /usr/include/openssl/opensslconf.h:42:0,
                   from /usr/include/openssl/crypto.h:32,
                   from /usr/include/openssl/bio.h:20,
                   from /usr/include/openssl/err.h:21,
                   from SWIG/_m2crypto_wrap.c:3828:
  /usr/include/openssl/rand.h:47:1: note: declared here
   DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num))

最佳答案

尝试使用 compat-openssl10-devel:

sudo dnf install compat-openssl10-devel --allowerasing

如果与 open-ssl 冲突,您可能必须删除它。您可以在安装 M2Crypto 后重新安装 open-ssl

关于Fedora 26 中 Python M2Crypto 安装失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48746163/

相关文章:

java - 创建从 Java 客户端(在 Android 上)到 Python 服务器的自签名 SSL 套接字

python - 优化Python在层次字典中的键搜索

python - 是否有用于 python 的通用二进制协议(protocol)编解码器库?

Python x509 get_serial_number() 返回不正确的值

python - pip 安装 M2Crypto 失败

python - 使用 Python 在 sudo 之后获取父用户

m2crypto - 无法在 Mac M1 上安装 M2Crypto

linux - 在 Fedora 26 上安装 mbstring

docker - 如何在 Fedora 26 上将 docker 镜像推送到 Docker Hub?