M2Crypto 未安装在 venv 中,或者 swig 未定义 __x86_64__ ,这会破坏针对 OpenSSL 的编译

发布于 2024-12-09 16:12:46 字数 2389 浏览 0 评论 0原文

我正在尝试将 Python M2Crypto 包安装到 x86_64 RHEL 6.1 计算机上的 virtualenv 中。此过程调用 swig,它会失败并出现以下错误:

$ 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。

/usr/include/openssl/opensslconf.h 导致错误的部分如下所示:

#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 定义了正确的变量:

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

但显然 swig 没有,因为这是失败的行:

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

有没有办法解决这个问题通过更改我的系统配置中的某些内容? M2Crypto 作为我无法控制的较大脚本的一部分安装在 virtualenv 中,因此避免乱搞 M2Crypto 文件将是一件好事。

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:

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

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 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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

浪漫之都 2024-12-16 16:12:46

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

pip 安装失败后,会将下载的内容留在 venv/build/M2Crypto 目录中。这样做:

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

这在我的安装过程中有效

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.

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

独享拥抱 2024-12-16 16:12:46

您只是没有安装swig

尝试:

sudo yum install swig

然后:

sudo easy_install M2crypto

You just don't have swig installed.

Try:

sudo yum install swig

And then:

sudo easy_install M2crypto
停滞 2024-12-16 16:12:46

我这样做了,效果很好:

env SWIG_FEATURES="-cpperraswarn -includeall -I/usr/include/openssl" pip install M2Crypto

当然,你必须先用 sudo yum install swig 安装 swigg

I did this and it works very well :

env SWIG_FEATURES="-cpperraswarn -includeall -I/usr/include/openssl" pip install M2Crypto

Of course you have to install swigg with sudo yum install swig before

玉环 2024-12-16 16:12:46

如果您在 Ubuntu 上看到此情况,请使用 apt-get 而不是 pip 来避免此问题。

apt-get install python-m2crypto

If you are seeing this and are on Ubuntu, use apt-get instead of pip to avoid this issue.

apt-get install python-m2crypto

七七 2024-12-16 16:12:46

我遇到了类似的问题,其中缺少 /usr/include/openssl opensslconf.h
(来源https://bugs.debian.org/cgi-bin/bugreport.cgi?错误=733644#10

sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl

I had a similar issue where /usr/include/openssl was missing opensslconf.h
(source https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733644#10)

sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl
流云如水 2024-12-16 16:12:46

有一个可以使用“pip install”的存储库:

https://github.com/martinpaljak/M2Crypto

There's a repository where "pip install" works:

https://github.com/martinpaljak/M2Crypto

池予 2024-12-16 16:12:46
sudo yum install m2crypto

为我解决了这个问题。

sudo yum install m2crypto

worked for me to get around this problem.

南风起 2024-12-16 16:12:46

我在centos5.8中找到了解决这个问题的新方法,试试吧。

vim setup.py

def finalize_options(self):
  ...
  self.swig_opts.append('-includeall') # after this line
  self.swig_opts.append('-I/usr/include/openssl') # add here

然后 python setup.py install 就可以工作了。

I found a new way to fix this problem in centos5.8, try it.

vim setup.py

def finalize_options(self):
  ...
  self.swig_opts.append('-includeall') # after this line
  self.swig_opts.append('-I/usr/include/openssl') # add here

then python setup.py install will work.

携余温的黄昏 2024-12-16 16:12:46

在 FreeBSD 上,我还必须安装 Swig(明显的部分)(通过 sudo pkg install swig),但 Swig 2.0 可执行文件被命名为 swig2.0 并处理 swig 导致找不到命令。解决方案:符号链接 Swig 2.0 来处理 swig:

ln -s /usr/local/bin/swig2.0 /usr/local/bin/swig

On FreeBSD I had to install Swig (the obvious part) as well (by sudo pkg install swig), but Swig 2.0 executable was named swig2.0 and handle swig resulted in command not found. Solution: symlink Swig 2.0 to handle swig:

ln -s /usr/local/bin/swig2.0 /usr/local/bin/swig
唯憾梦倾城 2024-12-16 16:12:46

正如@LeoC 所说,似乎不喝水是问题所在。

对于 MacOS 上的用户,我建议通过像 homebrew 这样的包管理器下载 swig,因为它更干净。

即你会跑

brew install swig

It seems like not having swig is the problem, as @LeoC said.

For those on MacOS, I'd recommend downloading swig via a package manager like homebrew because it's cleaner.

I.e. you'd run

brew install swig

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文