Error while Installing sqlite using pip on Python 2.7.13

本秂侑毒 提交于 2019-12-08 01:35:03

问题


I am trying to install pysqlite using pip but it keeps giving me an error:

Cannot open include file: 'sqlite3.h': No such file or directory

I'm using Windows 10 OS 64 bit. Python version 2.7.13. I'm trying to install using pip. (pip install pysqlite)

I'm unable to share the error screenshot so I have copied the complete error code below. If anyone can help me, that will be great. Thank you.

The complete cmd looks like this:

C:\Users\Who Are You>pip install pysqlite
Collecting pysqlite
  Using cached pysqlite-2.8.3.tar.gz
Installing collected packages: pysqlite
  Running setup.py install for pysqlite ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\whoare~1\\appdata\\local\\temp\\pip-build-0ju9tj\\pysqlite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\whoare~1\appdata\local\temp\pip-0cieyz-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    creating build\lib.win32-2.7\pysqlite2
    copying lib\dbapi2.py -> build\lib.win32-2.7\pysqlite2
    copying lib\dump.py -> build\lib.win32-2.7\pysqlite2
    copying lib\__init__.py -> build\lib.win32-2.7\pysqlite2
    creating build\lib.win32-2.7\pysqlite2\test
    copying lib\test\dbapi.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\dump.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\factory.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\hooks.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\regression.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\transactions.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\types.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\userfunctions.py -> build\lib.win32-2.7\pysqlite2\test
    copying lib\test\__init__.py -> build\lib.win32-2.7\pysqlite2\test
    running build_ext
    building 'pysqlite2._sqlite' extension
    creating build\temp.win32-2.7
    creating build\temp.win32-2.7\Release
    creating build\temp.win32-2.7\Release\src
    C:\Users\Who Are You\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DMODULE_NAME=\"pysqlite2.dbapi2\" -I'{' -Iis -Inot -Irecognized -Ias -Ian -Iinternal -Ior -Iexternal -Icommand, -Ioperable -Iprogram -Ior -Ibatch -Ifile. -Ic:\python27\include -Ic:\python27\PC /Tcsrc/module.c /Fobuild\temp.win32-2.7\Release\src/module.obj
    module.c
    c:\users\who are you\appdata\local\temp\pip-build-0ju9tj\pysqlite\src\connection.h(33) : fatal error C1083: Cannot open include file: 'sqlite3.h': No such file or directory
    error: command 'C:\\Users\\Who Are You\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2
    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\whoare~1\\appdata\\local\\temp\\pip-build-0ju9tj\\pysqlite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\whoare~1\appdata\local\temp\pip-0cieyz-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\whoare~1\appdata\local\temp\pip-build-0ju9tj\pysqlite\

Screenshot is here


回答1:


I had the same issue and managed to solve it this way:

  1. Create a temporary directory C:\sqlite
  2. Copy the files lib.exe, link.exe and mspdb80.dll to C:\sqlite from:
    • For X86 build: %LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin
    • For X64 build: %LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\amd64
  3. Download amalgamated source code and precompiled binaries for Windows (32-bit or 64-bit DLL files) archives from SQLite website
  4. Extract the binary files archive (sqlite3.dll and sqlite3.def) to C:\sqlite
  5. Open Windows PowerShell in C:\sqlite and run:
    • For X86 build: .\lib.exe /DEF:sqlite3.def /MACHINE:X86
    • For X64 build: .\lib.exe /DEF:sqlite3.def /MACHINE:X64
  6. Copy the created sqlite3.lib file to C:\Python27\libs
  7. From the amalgamated source code archive extract sqlite3.h and sqlite3ext.h to C:\Python27\include
  8. Run pip install pysqlite



回答2:


As far as i can remember sqlite3 is inbuilt in python2.x and python3.x



来源:https://stackoverflow.com/questions/46288737/error-while-installing-sqlite-using-pip-on-python-2-7-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!