How can I import the sqlite3 module into Python 2.4?

后端 未结 4 1525
再見小時候
再見小時候 2021-01-05 05:50

The sqlite3 module is included in Python version 2.5+. However, I am stuck with version 2.4. I uploaded the sqlite3 module files, added the directory to sys.path, but I get

相关标签:
4条回答
  • 2021-01-05 06:04

    You must ensure your sqlite, sqlite-devel, python-sqlite are installed correctly first and then recompile Python.

    0 讨论(0)
  • 2021-01-05 06:07

    Did you install it? That often works better than messing with sys.path.

    python setup.py install
    

    If so, you should then find it.

    If, for some reason, you can't install it, set the PYTHONPATH environment variable. Do not make a habit of messing with sys.path.

    0 讨论(0)
  • 2021-01-05 06:16

    I had same problem with CentOS and python 2.4

    My solution:

    yum install python-sqlite2
    

    and try following python code

    try:
        import sqlite3
    except:
        from pysqlite2 import dbapi2 as sqlite3
    
    0 讨论(0)
  • 2021-01-05 06:18

    You will need to install pysqlite. Notice, however, that this absolutely does require a compiler, unless you can find binaries for it (and Python 2.4) on the net. Using the 2.5 binaries will not be possible.

    0 讨论(0)
提交回复
热议问题