我需要在64位CentOS中运行32位Python.
背景
我有一个PCI-GPIB接口卡.它的驱动程序来自National Instruments.它在驱动程序页面中说:
NI-488.2 version 2.9 supports 64-bit kernels. The driver may currently be used only from 32-bit applications.
使用Python的驱动程序
我使用PyVISA包装器来使用驱动程序,如下所示:
import visa
但是,我收到以下错误:
OSError: /usr/local/vxipnp/linux/bin/libvisa.so.7: wrong ELF class: ELFCLASS32
题
National Instruments表示他们的驱动程序支持64位内核.好.
但它只能在32位应用程序中使用.坏.我的Python安装(我自己编译)是64位.
如何在64位CentOS 6中编译32位Python?
解决方法:
以下是我在CentOS 6.10上构建32位Python 2.7.15的方法:
安装所需的包:
sudo yum install libgcc.i686 glibc-devel.i686 glibc.i686 zlib-devel.i686\
readline-devel.i686 gdbm-devel.i686 openssl-devel.i686 ncurses-devel.i686\
tcl-devel.i686 db4-devel.i686 bzip2-devel.i686
构建32位Python:
mkdir ${HOME}/{Archive,Build}
wget http://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz -O ${HOME}/Archive/Python-2.7.15.tgz
tar xzvf ~/Archive/Python-2.7.15.tgz -C ${HOME}/Build
cd ${HOME}/Build/Python-2.7.15
[sudo] mkdir -p /opt/Python-2.7.15
CFLAGS=-m32 LDFLAGS=-m32 ./configure --prefix=/E/.sbx/Python-2.7.15 --enable-shared
LD_RUN_PATH=/opt/Python-2.7.15/lib make
make install