安装pip
(要下载whl,会比较慢,建议上梯子)
curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
sudo python get-pip.py
pip --version
安装gdal
pip install gdal -i https://pypi.tuna.tsinghua.edu.cn/simple
安装psycopg2
读postgresql库
pip install psycopg2-binary -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 链接sqlite
import sqlite3
conn2 = sqlite3.connect(dbfile)
conn2.enable_load_extension(True)
conn2.load_extension('/usr/local/lib/mod_spatialite') # 启用空间扩展
c2 = conn2.cursor()
sql = "PRAGMA table_info(''table1);"
cursor_cols = c2.execute(sql)
python2 链接sqlite
import pyspatialite.dbapi2 as db
con = db.connect(dbfile)
cursor = con.execute('SELECT sqlite_version(), spatialite_version()') # 测试版本
print cursor.fetchall()