如何在 64 位 Ubuntu 上安装 32 位 python

Mar*_*oma 9 64-bit python 32-bit

我使用的是 Ubuntu 10.10 ( Linux pc07 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:46 UTC 2011 x86_64 GNU/Linux) 和默认的 python 包 (Python 2.6.6)。

我想安装python-psyco以提高我的一个脚本的性能,但仅python-psyco-doc适用于 64 位。我尝试了虚拟机,但虚拟机上的性能提升远低于“真实”安装的 32 位 Ubuntu。

所以我的问题是:如何在我的 64 位 Ubuntu 机器上安装带有 psyco 的 32 位 Python?

编辑:我找到了这篇文章并做了这个:

  • http://python.org/download/下载“Python 2.7.1 bzipped 源 tarball”
  • 进入解压“Python 2.7.1”的目录
  • OPT=-m32 LDFLAGS=-m32 ./configure --prefix=/opt/pym32
  • make

但我收到了这个错误:

gcc -pthread -m32 -Xlinker -export-dynamic -o python \
            Modules/python.o \
            libpython2.7.a -lpthread -ldl  -lutil   -lm  
libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/home/moose/Downloads/Python-2.7.1/./Modules/posixmodule.c:7346: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/home/moose/Downloads/Python-2.7.1/./Modules/posixmodule.c:7301: warning: the use of `tempnam' is dangerous, better use `mkstemp'
Segmentation fault
make: *** [sharedmods] Fehler 139
Run Code Online (Sandbox Code Playgroud)

编辑 2:现在我找到了http://indefinestudies.org/2010/02/08/how-to-build-32-bit-python-on-ubuntu-9-10-x86_64/似乎这有效:

  • cd Python-2.7.1
  • CC="gcc -m32" LDFLAGS="-L/lib32 -L/usr/lib32 \ -L密码/lib32 -Wl,-rpath,/lib32 -Wl,-rpath,/usr/lib32" \ ./configure --prefix=/opt/pym32
  • make
  • sudo make install

但是安装 psyco 不起作用:

出现这个错误:

PROCESSOR = 'ivm'
running install
running build
running build_py
running build_ext
building 'psyco._psyco' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DALL_STATIC=1 -Ic/ivm -I/usr/include/python2.6 -c c/psyco.c -o build/temp.linux-x86_64-2.6/c/psyco.o
In file included from c/psyco.c:1:
c/psyco.h:9: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden
compilation terminated.
error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

安装包python-dev解决了问题,但我仍然无法使用psyco。现在我已经安装了 32 位 Ubuntu 系统。

Jam*_*ess 7

要在 64 位 Ubuntu 系统上运行 32 位应用程序,您需要ia32-libs. 从终端,验证您是否有这个使用

dpkg -l ia32-libs
Run Code Online (Sandbox Code Playgroud)

如果你已经安装了它,输出应该是这样的:

ii   ia32-libs ...
Run Code Online (Sandbox Code Playgroud)

如果它看起来像un ia32-libs,则需要使用以下方法安装它:

sudo apt-get install ia32-libs
Run Code Online (Sandbox Code Playgroud)