当前位置: 代码迷 >> python >> 在Fedora 26中Python M2Crypto安装失败
  详细解决方案

在Fedora 26中Python M2Crypto安装失败

热度:58   发布时间:2023-07-16 11:03:19.0

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

OpenSSL的-devel的

包。 现在我正在尝试安装

M2Crypto == 0.25.1

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

点安装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