使用python3支持在virtualenv中安装pysqlite

Mat*_*łło 4 python sqlite pip virtualenv python-3.x

我用以下方法创建了virtualenv:

mkvirtualenv -p /usr/bin/python3.4 django
Run Code Online (Sandbox Code Playgroud)

之后,我尝试安装pysqlite:

pip install pysqlite
Run Code Online (Sandbox Code Playgroud)

但我得到了:

Downloading/unpacking pysqlite
  Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded
  Running setup.py (path:/home/sigo/.virtualenvs/django/build/pysqlite/setup.py) egg_info for package pysqlite
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/home/sigo/.virtualenvs/django/build/pysqlite/setup.py", line 85
        print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
                                                                           ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/home/sigo/.virtualenvs/django/build/pysqlite/setup.py", line 85

    print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."

                                                                       ^

SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

看来pip尝试使用python2.我该如何解决这个问题?

gha*_*ing 8

Python 3.x没有pysqlite的公共版本.对于Python 3.x,标准库中的sqlite3模块是pysqlite的最新版本.

  • 如果您下载最新的sqlite-autoconf-*文件并使用./configure --prefix =/opt/sqlite3 make -j4 install安装它,那么它默认使用fts3和rtree扩展构建.然后,您可以导出LD_LIBRARY_PATH =/opt/sqlite3/lib,然后启动Python进程将获取刚刚安装的sqlite3库.在Mac上,它是DYLD_LIBRARY_PATH. (2认同)