Anaconda错误:无法打开包含文件:'sqlite3.h':没有这样的文件或目录

时间:2018-03-25 02:05:57

标签: python pip anaconda peewee

在Windows 10上,

pip install peewee在Anaconda上失败。

  • 操作系统:Windows 10
  • Python:Python 3.6.4 :: Anaconda,Inc。
  • Cython: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?

2 个答案:

答案 0 :(得分:0)

我在安装了VisualStudio 2017社区和Anaconda 3的Win7-X86上遇到了同样的问题。 问题是在使用C / C ++编译器编译期间找不到sqlite3.h。 文件在Library \ Include中的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

答案 1 :(得分:0)

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

$ NO_SQLITE=1 python setup.py build