本文介绍了M2Crypto未安装在venv中,或者swig未定义__x86_64__,这破坏了针对OpenSSL的编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Python M2Crypto软件包安装到x86_64 RHEL 6.1计算机上的virtualenv中.此过程将调用swig,该失败将失败,并显示以下错误:

I'm trying to install the Python M2Crypto package into a virtualenv on an x86_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error:

$ virtualenv -q --no-site-packages venv
$ pip install -E venv M2Crypto==0.20.2
Downloading/unpacking M2Crypto==0.20.2
  Downloading M2Crypto-0.20.2.tar.gz (412Kb): 412Kb  downloaded
  Running setup.py egg_info for package M2Crypto
Installing collected packages: M2Crypto
  Running setup.py install for M2Crypto
    building 'M2Crypto.__m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    swig -python -I/usr/include/python2.6 -I/usr/include -includeall -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    /usr/include/openssl/opensslconf.h:31: Error: CPP #error ""This openssl-devel package does not work your architecture?"". Use the -cpperraswarn option to continue swig processing.
    error: command 'swig' failed with exit status 1
    Complete output from command /home/lorin/venv/bin/python -c "import setuptools;__file__='/home/lorin/venv/build/M2Crypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-BFiNtU-record/install-record.txt --install-headers /home/lorin/venv/include/site/python2.6:

我已经通过RedHat的RPM软件包安装了OpenSSL 1.0.0.

I've got OpenSSL 1.0.0 installed via RPM packages from RedHat.

/usr/include/openssl/opensslconf.h中导致错误的部分看起来像这样:

The part of /usr/include/openssl/opensslconf.h that causes the error looks like this:

#if defined(__i386__)
#include "opensslconf-i386.h"
#elif defined(__ia64__)
#include "opensslconf-ia64.h"
#elif defined(__powerpc64__)
#include "opensslconf-ppc64.h"
#elif defined(__powerpc__)
#include "opensslconf-ppc.h"
#elif defined(__s390x__)
#include "opensslconf-s390x.h"
#elif defined(__s390__)
#include "opensslconf-s390.h"
#elif defined(__sparc__) && defined(__arch64__)
#include "opensslconf-sparc64.h"
#elif defined(__sparc__)
#include "opensslconf-sparc.h"
#elif defined(__x86_64__)
#include "opensslconf-x86_64.h"
#else
#error "This openssl-devel package does not work your architecture?"
#endif

gcc定义了正确的变量:

gcc has the right variable defined:

$ echo | gcc -E -dM - | grep x86_64
#define __x86_64 1
#define __x86_64__ 1

但是明显的痛饮却没有,因为这是失败的那一行:

But apparenty swig doesn't, since this is the line that's failing:

swig -python -I/usr/include/python2.6 -I/usr/include -includeall -o \
  SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i

是否可以通过更改系统配置来解决此问题? M2Crypto被安装在virtualenv中,这是我无法控制的较大脚本的一部分,因此,避免与M2Crypto文件混在一起是一件好事.

Is there a way to fix this by changing something in my system configuration? M2Crypto gets installed in a virtualenv as part of a larger script I don't control, so avoiding mucking around with the M2Crypto files would be a good thing.

推荐答案

M2Crypto提供了fedora_setup.sh脚本来处理Fedora/RL/CentOs版本的问题,但是pip当然对此一无所知.

M2Crypto supplies a fedora_setup.sh script to handle the problems with Fedora/RL/CentOs releases, but pip, of course, doesn't know anything about it.

在pip安装失败后,它将下载的内容保留在venv/build/M2Crypto目录中.做到这一点:

After the pip install fails, it leaves the downloaded stuff in the venv/build/M2Crypto directory. do this:

cd <path-to-your-venv>/venv/build/M2Crypto
chmod u+x fedora_setup.sh
./fedora_setup.sh build
./fedora_setup.sh install

这已在我的安装过程中起作用

This has worked in my install process

这篇关于M2Crypto未安装在venv中,或者swig未定义__x86_64__,这破坏了针对OpenSSL的编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 22:59