Closed dlauc closed 7 years ago
Hey dlauc did you find a way to fix or bypass this error ? Cause i got the same here with Windows 10, VS 2015, Python 3.5
After a Google search, i found a thread concerning snprintf but i'm not good enough to assess its relevance : http://stackoverflow.com/questions/27754492/vs-2015-compiling-cocos2d-x-3-3-error-fatal-error-c1189-error-macro-definiti
Does somebody have an idea ? To be more accurate, there was this error message too :
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
I paste more of the log, it could be helpful.
trainer_wrapper.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -Icrfsuite/win32 -Ic:\users\mars\appdata\local\programs\python\python35-32\include -Ic:\users\mars\appdata\local\programs\python\python35-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /EHsc /Tccrfsuite/lib/crf/src\crf1d_context.c /Fobuild\temp.win32-3.5\Release\crfsuite/lib/crf/src\crf1d_context.obj
crf1d_context.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(262): warning C4005: 'isfinite': macro redefinition
crfsuite/include/os.h(49): note: see previous definition of 'isfinite'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1925): warning C4005: 'snprintf': macro redefinition
crfsuite/include/os.h(50): note: see previous definition of 'snprintf'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1927): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
I was trying to build the module for someone else and found that this should be enough to build with VS 2015:
$ diff crfsuite/include/os.h.org crfsuite/include/os.h
40c40
< #ifdef _MSC_VER
---
> #if _MSC_VER < 1900
I built it and ran tox on Python 35 (x86):
========== 1 failed, 46 passed, 1 skipped, 4 xfailed in 0.36 seconds ==========
The 1 failure was a file permission error that I did not investigate.
EDIT: nevermind, it's been fixed upstream, on crfsuite.
Is there any solution to this issue yet. I have same problem.
pip install sklearn-crfsuite
Collecting sklearn-crfsuite
Using cached sklearn_crfsuite-0.3.4-py2.py3-none-any.whl
Requirement already satisfied: tqdm>=2.0 in c:\programs\anaconda3\lib\site-packages (from sklearn-crfsuite)
Collecting python-crfsuite>=0.8.3 (from sklearn-crfsuite)
Using cached python-crfsuite-0.8.4.tar.gz
Requirement already satisfied: tabulate in c:\programs\anaconda3\lib\site-packages (from sklearn-crfsuite)
Requirement already satisfied: six in c:\programs\anaconda3\lib\site-packages (from sklearn-crfsuite)
Building wheels for collected packages: python-crfsuite
Running setup.py bdist_wheel for python-crfsuite ... error
Complete output from command c:\programs\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\vishwas\\AppData\\Local\\Temp\\pip-build-xsmyqn3i\\python-crfsuite\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\vishwas\AppData\Local\Temp\tmpx_v4omg5pip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\pycrfsuite
copying pycrfsuite\_dumpparser.py -> build\lib.win-amd64-3.5\pycrfsuite
copying pycrfsuite\_logparser.py -> build\lib.win-amd64-3.5\pycrfsuite
copying pycrfsuite\__init__.py -> build\lib.win-amd64-3.5\pycrfsuite
running build_ext
building 'pycrfsuite._pycrfsuite' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\pycrfsuite
creating build\temp.win-amd64-3.5\Release\crfsuite
creating build\temp.win-amd64-3.5\Release\crfsuite\lib
creating build\temp.win-amd64-3.5\Release\crfsuite\lib\crf
creating build\temp.win-amd64-3.5\Release\crfsuite\lib\crf\src
creating build\temp.win-amd64-3.5\Release\crfsuite\swig
creating build\temp.win-amd64-3.5\Release\crfsuite\lib\cqdb
creating build\temp.win-amd64-3.5\Release\crfsuite\lib\cqdb\src
creating build\temp.win-amd64-3.5\Release\liblbfgs
creating build\temp.win-amd64-3.5\Release\liblbfgs\lib
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -Icrfsuite/win32 -Ic:\programs\anaconda3\include -Ic:\programs\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" -IC:\Programs\Qt\4.8.6\include /EHsc /Tppycrfsuite/_pycrfsuite.cpp /Fobuild\temp.win-amd64-3.5\Release\pycrfsuite/_pycrfsuite.obj
_pycrfsuite.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -Icrfsuite/win32 -Ic:\programs\anaconda3\include -Ic:\programs\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" -IC:\Programs\Qt\4.8.6\include /EHsc /Tppycrfsuite/trainer_wrapper.cpp /Fobuild\temp.win-amd64-3.5\Release\pycrfsuite/trainer_wrapper.obj
trainer_wrapper.cpp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icrfsuite/include/ -Icrfsuite/lib/cqdb/include -Iliblbfgs/include -Ipycrfsuite -Icrfsuite/win32 -Ic:\programs\anaconda3\include -Ic:\programs\anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" -IC:\Programs\Qt\4.8.6\include /EHsc /Tccrfsuite/lib/crf/src\crf1d_context.c /Fobuild\temp.win-amd64-3.5\Release\crfsuite/lib/crf/src\crf1d_context.obj
crf1d_context.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\math.h(262): warning C4005: 'isfinite': macro redefinition
crfsuite/include/os.h(49): note: see previous definition of 'isfinite'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1925): warning C4005: 'snprintf': macro redefinition
crfsuite/include/os.h(50): note: see previous definition of 'snprintf'
C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt\stdio.h(1927): fatal error C1189: #error: Macro definition of snprintf conflicts with Standard Library function declaration
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Hey,
I think it is a problem with crfsuite library: crfsuite master is compatible with VS2015, but not with earlier VS versions; earlier crfsuite is compatible with other VS, but not compatible with VS2015. See https://github.com/chokkan/crfsuite/issues/65. So we have to choose whether to support VS2015 (and Python 3.5, but not other Python versions) or not to support it (and support all Python versions except for Python 3.5).
@fgregg sent a PR to bring back pre-VS2015 compatibility (https://github.com/chokkan/crfsuite/pull/66); I wonder if we should bundle this fix instead of using crfsuite master. There is also a couple other fixes which are not merged, so maybe using a fork is not that bad.
I wonder if we should bundle this fix instead of using crfsuite master. There is also a couple other fixes which are not merged, so maybe using a fork is not that bad.
How about bundling this for the time being and reverting that patch once the pull request gets merged? There does not seem to be any indication currently that this pull request is going to get merged any time soon.
As a workaround, this is what worked for me:
crfsuite/include/os.h
and remove the line with #define snprintf _snprintf
pip install C:\users\whatever\path\to\python-crfsuite
(effectively installing it from the locally cloned repository)The workaround mentioned by @PMeira (adding a < 1900
) didn't work for me, even though I have VS2015 installed (which should map to MSC_VER 1900).
That's weird, @petermorlion -- I tested that again right now and it worked fine (note that is not only adding < 1900
, the change is also from ifdef
to if
). This time I used the stand-alone Visual C++ 2015 Build Tools, with Windows 10 SDK. Maybe the difference is something related to the SDK version.
Again, note that the upstream version of crfsuite builds fine with MSVC 2015 (Python 3.5, 3.6). The issue is that it does not build with MSVC 2008 (Python 2.7). The pull request to fix that is open since April 2016. Since there were no commits in a year, I agree with @valgur's suggestion.
@PMeira must be something I did wrong in the .h file then. My knowledge of C++ doesn't extend much further than it's name :)
Could someone please share the whl file for py3.5/win64?
@petermorlion @PMeira @kmike
I have uploaded the wheel there: https://github.com/scrapinghub/python-crfsuite/issues/51#issuecomment-283244262
The following PR address the windows builds in conda: https://github.com/conda-forge/python-crfsuite-feedstock/pull/4
Closed by #66.
pip install on Windows, with VS 2015 halts with error: