Kan iemand me vertellen hoe ik de sqlite3-module kan installeren naast de meest recente versie van Python?
Ik gebruik een Macbook en op de opdrachtregel probeerde ik:
pip install sqlite
maar er verschijnt een foutmelding.
Antwoord 1, autoriteit 100%
U hoeft sqlite3
module. Het is opgenomen in de standaardbibliotheek (sinds Python 2.5).
Antwoord 2, autoriteit 22%
Voor Python versie 3:
pip install pysqlite3
Antwoord 3, autoriteit 18%
Ik heb python 2.7.3 en dit heeft mijn probleem opgelost:
pip install pysqlite
Antwoord 4, autoriteit 9%
Normaal gesproken is het inbegrepen. Echter, zoals @ngn999 al zei, als je python handmatig vanuit de bron is gebouwd, moet je deze toevoegen.
Hier is een voorbeeld van een script dat een ingekapselde versie (virtuele omgeving) van Python3in uw gebruikersdirectory opzet met een ingekapselde versie van sqlite3.
INSTALL_BASE_PATH="$HOME/local"
cd ~
mkdir build
cd build
[ -f Python-3.6.2.tgz ] || wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar -zxvf Python-3.6.2.tgz
[ -f sqlite-autoconf-3240000.tar.gz ] || wget https://www.sqlite.org/2018/sqlite-autoconf-3240000.tar.gz
tar -zxvf sqlite-autoconf-3240000.tar.gz
cd sqlite-autoconf-3240000
./configure --prefix=${INSTALL_BASE_PATH}
make
make install
cd ../Python-3.6.2
LD_RUN_PATH=${INSTALL_BASE_PATH}/lib configure
LDFLAGS="-L ${INSTALL_BASE_PATH}/lib"
CPPFLAGS="-I ${INSTALL_BASE_PATH}/include"
LD_RUN_PATH=${INSTALL_BASE_PATH}/lib make
./configure --prefix=${INSTALL_BASE_PATH}
make
make install
cd ~
LINE_TO_ADD="export PATH=${INSTALL_BASE_PATH}/bin:\$PATH"
if grep -q -v "${LINE_TO_ADD}" $HOME/.bash_profile; then echo "${LINE_TO_ADD}" >> $HOME/.bash_profile; fi
source $HOME/.bash_profile
Waarom doe dit? Misschien wilt u een modulaire Python-omgeving die u volledig kunt vernietigen en opnieuw opbouwen zonder uw beheerde pakketinstallatie te beïnvloeden. Dit zou je een onafhankelijke ontwikkelingsomgeving geven. In dit geval is de oplossing om SQLITE3-modulair ook te installeren.
Antwoord 5
Als u een fout in SQLite heeft gebouwd in Python, kunt u Conda gebruiken om dit conflict
op te lossen
conda install sqlite