Python 在windows中从源生成statsmodels时出错

Python 在windows中从源生成statsmodels时出错,python,numpy,statsmodels,Python,Numpy,Statsmodels,当我尝试使用Windows按照以下说明从源代码构建statsmodels时: 使用: python setup.py安装 我得到以下错误: 致命错误C1047:对象或库文件“C:\\Apps\\Anaconda3\\lib\\site packages\\numpy\\core\\lib\npymath.lib”是使用旧版本创建的 编译器而不是其他对象;重建旧对象和库 链接:致命错误LNK1257:代码生成失败 有什么办法解决这个问题吗?我使用Anaconda3和numpy版本1.13.1

当我尝试使用Windows按照以下说明从源代码构建statsmodels时:

使用:

python setup.py安装

我得到以下错误:


致命错误C1047:对象或库文件“C:\\Apps\\Anaconda3\\lib\\site packages\\numpy\\core\\lib\npymath.lib”是使用旧版本创建的
编译器而不是其他对象;重建旧对象和库
链接:致命错误LNK1257:代码生成失败

有什么办法解决这个问题吗?我使用Anaconda3和numpy版本1.13.1以及Microsoft Visual Studio 2017。
python setup.py install
的完整输出如下:

Cythonizing sources
statsmodels\nonparametric\linbin.pyx has not changed
statsmodels\nonparametric\_smoothers_lowess.pyx has not changed
statsmodels\tsa\kalmanf\kalman_loglike.pyx has not changed
statsmodels\tsa\regime_switching\_hamilton_filter.pyx.in has not changed
statsmodels\tsa\regime_switching\_kim_smoother.pyx.in has not changed
statsmodels\tsa\statespace\_kalman_filter.pyx.in has not changed
statsmodels\tsa\statespace\_kalman_smoother.pyx.in has not changed
statsmodels\tsa\statespace\_representation.pyx.in has not changed
statsmodels\tsa\statespace\_simulation_smoother.pyx.in has not changed
statsmodels\tsa\statespace\_statespace.pyx.in has not changed
statsmodels\tsa\statespace\_tools.pyx.in has not changed
statsmodels\tsa\statespace\_filters\_conventional.pyx.in has not changed
statsmodels\tsa\statespace\_filters\_inversions.pyx.in has not changed
statsmodels\tsa\statespace\_filters\_univariate.pyx.in has not changed
statsmodels\tsa\statespace\_smoothers\_alternative.pyx.in has not changed
statsmodels\tsa\statespace\_smoothers\_classical.pyx.in has not changed
statsmodels\tsa\statespace\_smoothers\_conventional.pyx.in has not changed
statsmodels\tsa\statespace\_smoothers\_univariate.pyx.in has not changed
running install
running bdist_egg
running egg_info
writing requirements to statsmodels.egg-info\requires.txt
writing statsmodels.egg-info\PKG-INFO
writing top-level names to statsmodels.egg-info\top_level.txt
writing dependency_links to statsmodels.egg-info\dependency_links.txt
package init file 'statsmodels\tsa\vector_ar\data\__init__.py' not found (or not a regular file)
reading manifest file 'statsmodels.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.pxi' anywhere in distribution
warning: no previously-included files matching '*' found under directory 'dist'
warning: no previously-included files found matching 'docs\source\generated\*'
warning: no previously-included files matching '*' found under directory 'docs\build'
warning: no previously-included files matching '*' found under directory 'docs\build\htmlhelp'
warning: no files found matching 'statsmodels\statsmodelsdoc.chm'
no previously-included directories found matching '*\__pycache__'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.swp' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.bak' found anywhere in distribution
writing manifest file 'statsmodels.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
copying statsmodels\version.py -> build\lib.win-amd64-3.5\statsmodels
running build_ext
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
building 'statsmodels.tsa.statespace._statespace' extension
C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Istatsmode
ls/src -IC:\\Apps\\Anaconda3\\lib\\site-packages\\numpy\\core\\include -IC:\Apps\Anaconda3\lib\site-packages\numpy\core\include -IC:\Apps\Anaco
nda3\include -IC:\Apps\Anaconda3\include -I"C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\Include" -I"C:\Apps\Micros
oft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\Include" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\share
d" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" -I"
C:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" /Tcstatsmodels/tsa/statespace/_statespace.c /Fobuild\temp.win-amd64-3.5\Relea
se\statsmodels/tsa/statespace/_statespace.obj
C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /nodefaultlib:l
ibucrt.lib ucrt.lib /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\\Apps\\Anaconda3\\lib\\site-packages\\numpy\\core\\lib /LIBPATH:C:\Ap
ps\Anaconda3\libs /LIBPATH:C:\Apps\Anaconda3\PCbuild\amd64 /LIBPATH:"C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\L
ib\x64" /LIBPATH:"C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\Lib\x64" /LIBPATH:"C:\Program Files (x86)\Win
dows Kits\10\lib\10.0.15063.0\um\x64" /LIBPATH:C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319 /LIBPATH:"C:\Program Files (x86)\Windows Kits\10
\lib\10.0.15063.0\ucrt\x64" npymath.lib /EXPORT:PyInit__statespace build\temp.win-amd64-3.5\Release\statsmodels/tsa/statespace/_statespace.obj
/OUT:build\lib.win-amd64-3.5\statsmodels\tsa\statespace\_statespace.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\statsmodels/tsa
/statespace\_statespace.cp35-win_amd64.lib
fatal error C1047: The object or library file 'C:\\Apps\\Anaconda3\\lib\\site-packages\\numpy\\core\\lib\npymath.lib' was created with an older
 compiler than other objects; rebuild old objects and libraries
LINK : fatal error LNK1257: code generation failed
error: Command "C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\link.exe /nologo /INCREMENTAL:NO /LTCG
 /nodefaultlib:libucrt.lib ucrt.lib /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\\Apps\\Anaconda3\\lib\\site-packages\\numpy\\core\\li
b /LIBPATH:C:\Apps\Anaconda3\libs /LIBPATH:C:\Apps\Anaconda3\PCbuild\amd64 /LIBPATH:"C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MS
VC\14.11.25503\Lib\x64" /LIBPATH:"C:\Apps\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\ATLMFC\Lib\x64" /LIBPATH:"C:\Program
 Files (x86)\Windows Kits\10\lib\10.0.15063.0\um\x64" /LIBPATH:C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319 /LIBPATH:"C:\Program Files (x86)
\Windows Kits\10\lib\10.0.15063.0\ucrt\x64" npymath.lib /EXPORT:PyInit__statespace build\temp.win-amd64-3.5\Release\statsmodels/tsa/statespace/
_statespace.obj /OUT:build\lib.win-amd64-3.5\statsmodels\tsa\statespace\_statespace.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release
\statsmodels/tsa/statespace\_statespace.cp35-win_amd64.lib" failed with exit status 1257

这是Python 3.6.3上的一个
distutils
问题

解决方法:
在statsmodels github中有一个大线程:


但简而言之,将numpy更新为1.14.3似乎解决了这个问题。在您的错误消息中,我看到“C:\\Apps\\Anaconda3\\lib\\site packages\\numpy\\core\\lib\npymath.lib”,Anaconda3附带statsmodels库@visweswaran nagasivam是的,当然,但我不打算使用statsmodels的Anaconda版本,而是Anaconda中尚未提供的开发版本,因此我需要从源代码构建它
"%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64
set DISTUTILS_USE_SDK=1
python setup.py install