[英]Installing pylint without installing libffi-dev (No module named '_ctypes')
[英]python “ModuleNotFoundError: No module named '_ctypes'” error on a shared host (no ability to sudo install libffi-dev)
我在一個共享主機上,他們正在運行 CentOS 和一個古老版本的 python,它幾乎沒有任何東西。 我已經編譯了 python 3.8,它可以工作,但是當我嘗試使用 pip 運行任何東西或運行 setup.py 文件時,我不斷得到
ModuleNotFoundError: No module named '_ctypes'
錯誤。
如果我沒有 root 訪問權限,如何在我構建的 Python 中獲得 _ctypes 支持?
我已經嘗試過的各種東西:
在過去的 3 天里,我一直在撓頭,似乎沒有任何效果。 但是,設置一些標志會有所幫助。 我假設你想在 CentOS 中構建沒有 root 訪問權限。 一個關鍵點是使用 --with-system-ffi 標志。 詳情如下,祝你好運。
第 1 步:確保已安裝 libffi 第 2 步:分配路徑 第 3 步:安裝 Python 並使用正確的標志
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
安裝 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
對於您的整套 GEOPACKAGES,您將需要分配以下系統變量(不僅適用於 libffi,而且適用於所有軟件包):
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>
在 CentOS 中安裝 Python,無需 root 訪問
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.