【问题标题】:Anaconda error: Cannot open include file: 'sqlite3.h': No such file or directoryAnaconda 错误:无法打开包含文件:'sqlite3.h':没有这样的文件或目录
【发布时间】:2018-09-03 10:33:12
【问题描述】:

pip install peewee 在 Windows 10 上使用 Anaconda 失败。

  • 操作系统:Windows 10
  • Python:Python 3.6.4 :: Anaconda, Inc.
  • 赛通:0.27.3

错误

playhouse\_sqlite_ext.c(531): fatal error C1083: Cannot open include file: 'sqlite3.h': No such file or directory error: command 'D:\\MyIDE\\VS2015\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

但是当我在没有Anaconda的情况下使用官方Python时,它安装成功。那么如何在Anaconda中使用Python成功安装peewee呢?

【问题讨论】:

  • 您使用pip 而不是conda 为Anaconda 安装peewee 有什么原因吗?
  • 我的猜测是,对于 python.org Python,要么 (a) pip 找到一个与你的构建完全匹配的轮子,(b) 包可以告诉你没有 sqlite3 C标头并跳过构建 sqlite 连接器,或者 (c) 包可以找到并使用 sqlite3 C 标头;对于 Anaconda,pip 改为尝试使用用于构建 stdlib sqlite3 模块的相同 C 头文件从源代码构建,但这些头文件不存在;使用conda,您只需将包从 conda 存储库中取出,一切都会好起来的。
  • @abarnert 和 conda install peewee,它产生 PackagesNotFoundError。使用 anaconda search -t conda peewee,我找不到正确的包。
  • 啊,你不知道 conda-forge 的社区包吗?有关 Peewee 包,请参阅 here,它还显示了如何从 conda-forge 安装包。
  • @abarnert 你帮我省了很多时间,唯一遗憾的是peewee的版本有点老了,才2.10.2。

标签: python pip anaconda peewee


【解决方案1】:

我在安装了 VisualStudio 2017 Community 和 Anaconda 3 的 Win7-X86 上遇到了同样的问题。 问题是在使用 C/C++ 编译器编译时找不到 sqlite3.h。 文件在库\包含中的 Anaconda 安装中可用。 在链接期间,您不会在 Library\include 中找到 sqlite3.lib。 您可以添加适当的 CL 和 LINK 环境变量来解决问题。

下面介绍了 pyx.bat 来启动 python.exe 并使用其他环境变量来解决问题。不要忘记在 BAT 中为您的位置修复 PYTHONPATH,或者在系统级环境中需要它。 从命令行使用它:

pyx -m pip install -U peewee

我在 PATH 上有这个 pyx.bat,而路径上没有 Python

@echo off
setlocal
:: variable PYTHONHOME may be required for the Python.exe.
if "%PYTHONHOME%" == "" (
REM set PYTHONHOME=c:\Progs\Python
REM set PYTHONHOME=c:\Progs\Anaconda3x86
set PYTHONHOME=d:\InstSoft\Python\Anaconda3x86
REM set PYTHONHOME=d:\InstSoft\Python\Python361x86bin
)

set PY_EXE=Python
set PY_RUN=%PYTHONHOME%\%PY_EXE%.exe
if NOT exist "%PY_RUN%" (
  echo Missing: %PY_RUN%
  echo Check environment variable:
  echo PYTHONHOME=%PYTHONHOME%
  goto :eof
)

:: below required to run pip or conda, problems with py.bat:
:: conda may not find pythonw.exe since py.bat don't need PATH
:: covering PYTHONHOME, add it here:
set PATH=%PYTHONHOME%;%PATH%

:: conda or pip install may use VisualStudio and some headers/libs not found
:: while available at %PYTHONHOME% inside Library\include and Library\lib
:: (may happen when pip is used with Anaconda)
set CL=/I%PYTHONHOME%\Library\Include
set LINK=/LIBPATH:%PYTHONHOME%\Library\lib

echo Run: %PY_RUN%
echo Arg: %*
"%PY_RUN%" %*

:: eof

【讨论】:

    【解决方案2】:

    从 3.1.x 开始,您应该能够指定一个环境变量来跳过 sqlite 扩展的编译。参见文档:http://docs.peewee-orm.com/en/latest/peewee/installation.html#skip-compilation-of-sqlite-extensions

    $ NO_SQLITE=1 python setup.py build
    

    【讨论】:

    • conda install -c conda-forge peewee就行了,peewee的版本现在是v3.1.5,对我来说已经够用了。
    猜你喜欢
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2017-02-12
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-13
    相关资源
    最近更新 更多