在 Python 2.7.13 上使用 pip 安装 sqlite 时出错 [英] Error while Installing sqlite using pip on Python 2.7.13

查看:162
本文介绍了在 Python 2.7.13 上使用 pip 安装 sqlite 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 pip 安装 pysqlite,但它一直给我一个错误:

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

无法打开包含文件:'sqlite3.h':没有那个文件或目录

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

我使用的是 64 位 Windows 10 操作系统.Python 版本 2.7.13.我正在尝试使用 pip 安装.(pip 安装 pysqlite)

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.

完整的 cmd 如下所示:

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\

屏幕截图在这里

推荐答案

我遇到了同样的问题,并设法通过这种方式解决了:

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

  1. 创建一个临时目录C:\sqlite
  2. 将文件lib.exelink.exemspdb80.dll 复制到C:\sqlite从:
    • 对于 X86 版本:%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin
    • 对于 X64 构建:%LocalAppData%\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\amd64
  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
  • 对于 X86 版本:.\lib.exe/DEF:sqlite3.def/MACHINE:X86
  • 对于 X64 版本:.\lib.exe/DEF:sqlite3.def/MACHINE:X64

这篇关于在 Python 2.7.13 上使用 pip 安装 sqlite 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆