Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error C2143 failed with exit status 2 when using pip install from Anaconda #57

Open
ktnr opened this issue Jun 9, 2020 · 5 comments
Open

Comments

@ktnr
Copy link

@ktnr ktnr commented Jun 9, 2020

I tried to pip install the repo in a conda environment and VS19. I got the following error. (I do have installed the "Microsoft Visual C++ 2015-2019 Redistributable - 14.25.28508" for x86 and x64.)

(pybindenv) C:\Users\Leo\Source\Repos\pybind>pip install .
Processing c:\users\leo\source\repos\pybind
Building wheels for collected packages: python-example
  Building wheel for python-example (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Leo\Anaconda3\envs\pybindenv\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\setup.py'"'"'; __file__='"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\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\Leo\AppData\Local\Temp\pip-wheel-b07wghh7'
       cwd: C:\Users\Leo\AppData\Local\Temp\pip-req-build-kagahwum\
  Complete output (12 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'python_example' extension
  creating build
  creating build\temp.win-amd64-3.8
  creating build\temp.win-amd64-3.8\Release
  creating build\temp.win-amd64-3.8\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DVERSION_INFO="0.0.1" -Ic:\users\leo\appdata\local\temp\pip-req-build-kagahwum\.eggs\pybind11-2.5.0-py3.8.egg\pybind11\include -IC:\Users\Leo\Anaconda3\envs\pybindenv\include -IC:\Users\Leo\Anaconda3\envs\pybindenv\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpsrc/main.cpp /Fobuild\temp.win-amd64-3.8\Release\src/main.obj /EHsc
  main.cpp
  src/main.cpp(36): error C2143: Syntaxfehler: Es fehlt ";" vor "Konstante"
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for python-example
  Running setup.py clean for python-example
Failed to build python-example
Installing collected packages: python-example
    Running setup.py install for python-example ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Leo\Anaconda3\envs\pybindenv\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\setup.py'"'"'; __file__='"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\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\Leo\AppData\Local\Temp\pip-record-uxtepnq8\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Leo\Anaconda3\envs\pybindenv\Include\python-example'
         cwd: C:\Users\Leo\AppData\Local\Temp\pip-req-build-kagahwum\
    Complete output (12 lines):
    running install
    running build
    running build_ext
    building 'python_example' extension
    creating build
    creating build\temp.win-amd64-3.8
    creating build\temp.win-amd64-3.8\Release
    creating build\temp.win-amd64-3.8\Release\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DVERSION_INFO="0.0.1" -Ic:\users\leo\appdata\local\temp\pip-req-build-kagahwum\.eggs\pybind11-2.5.0-py3.8.egg\pybind11\include -IC:\Users\Leo\Anaconda3\envs\pybindenv\include -IC:\Users\Leo\Anaconda3\envs\pybindenv\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpsrc/main.cpp /Fobuild\temp.win-amd64-3.8\Release\src/main.obj /EHsc
    main.cpp
    src/main.cpp(36): error C2143: Syntaxfehler: Es fehlt ";" vor "Konstante"
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Leo\Anaconda3\envs\pybindenv\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\setup.py'"'"'; __file__='"'"'C:\\Users\\Leo\\AppData\\Local\\Temp\\pip-req-build-kagahwum\\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\Leo\AppData\Local\Temp\pip-record-uxtepnq8\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Leo\Anaconda3\envs\pybindenv\Include\python-example' Check the logs for full command output.

(pybindenv) C:\Users\Leo\Source\Repos\pybind>

Any idea what the issue is?

@rafael-fuente
Copy link

@rafael-fuente rafael-fuente commented Jun 9, 2020

I get the same error. I removed

#ifdef VERSION_INFO
    m.attr("__version__") = VERSION_INFO;
#else
    m.attr("__version__") = "dev";
#endif

from src/main.cpp and the error disappeared.

@ktnr
Copy link
Author

@ktnr ktnr commented Jun 10, 2020

Thanks for letting me know. It would be nice to know why. You also had the error with Anaconda and VS19, or is this a broader issue?

@rafael-fuente
Copy link

@rafael-fuente rafael-fuente commented Jun 10, 2020

I had the same error with Anaconda and with a python installation without Anaconda using VS19 MSVC compiler. Remplacing the lines with m.attr("__version__") = "dev"; from src/main.cpp also works.

@mihsamusev
Copy link

@mihsamusev mihsamusev commented Aug 10, 2020

Abovementioned fixes work for me as well

@magro11
Copy link

@magro11 magro11 commented Oct 10, 2020

I guess that this is no special Anaconda error. The problem seems to be, that a pre-processor variable does not have a defined datatype, such that VERSION_INFO="0.0.1" is not always considered to be a string (for instance in Visual Studio).

Please see this stackoverflow-article for a similar problem: https://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string

For me it worked (VS2017) to write the following code:

#ifdef VERSION_INFO
    #define STRINGIFY(x) #x
    #define TOSTRING(x) STRINGIFY(x)
    m.attr("__version__") = TOSTRING(VERSION_INFO);
#else
    m.attr("__version__") = "dev";
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.