I'm on a shared host, and they're running CentOS with an ancient version of python that lacks pretty much everything. I've compiled python 3.8, and that works, but when I try to run anything with pip or running a setup.py file, I keep getting the
ModuleNotFoundError: No module named '_ctypes'
error.
How do I get _ctypes support into a Python I build if I don't have root access?
Assorted things I've already tried:
I have been scratching my head for the past 3 days and nothing seemed to work. However, setting some flags helped. I assume you want to build without root access in CentOS. One key point is using --with-system-ffi flag. Details below and good luck.
Step-1: ensure libffi is installed Step-2: assign Path Step-3: install Python with proper flags
downloaddir='where you download zipped pacakges'
packagedir='where you unpack/unzip your downloaed files'
installdir='where you make local install'
threads=2 # number of threads available to accelerate installation
Install libffi
libffi_version=3.3
cd ${downloaddir}
wget ftp://sourceware.org/pub/libffi/libffi-${libffi_version}.tar.gz
tar xfvz libffi-${libffi_version}.tar.gz -C ${packagedir}
cd ${packagedir}/libffi-${libffi_version}/
./configure -v --prefix=${installdir} --disable-static
make -j${threads}
make install
For your whole set of GEOPACKAGES, you will need to assign the following system variables (not just for libffi but all packages):
export PATH=...
export CPATH=...
export LD_LIBRARY_PATH=...
export LIBRARY_PATH=...
export PKG_CONFIG_PATH=...<pkconfig>
export DSQLITE3_INCLUDE_DIR=...<sqlite3 header>
export DSQLITE3_LIBRARY=...<sqlite3 lib>
export LD_RUN_PATH=...<libdir>
Install Python in CentOS without root access
python_version=3.8.0
cd ${downloaddir}
wget https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz
tar zxfv Python-${python_version}.tgz -C ${packagedir}
${packagedir}/Python-${python_version}*
make clean
./configure --prefix=${installdir}/python/Python-${python_version} \
--enable-optimizations \
--with-lto \
--with-system-ffi \
--with-computed-gotos \
--enable-loadable-sqlite-extensions \
--with-ensurepip=install \
--includedir=${installdir}/include \
--with-system-ffi \
--with-openssl=${installdir} \
CFLAGS="-I${installdir}/include" \
CPPFLAGS="-I${installdir}/include" \
LDFLAGS="-L${installdir}/lib -L${installdir}/lib64" \
PKG_CONFIG_LIBDIR="-L${installdir}/lib/pkgconfig"
make -j${threads}
make altinstall
# update PATH
# export: LD_LIBRARY_PATH=... PATH=...
python -m ensurepip --upgrade
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.