mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.88k stars 562 forks source link

install fails under python 3.11 on Windows #1109

Closed zobac closed 1 year ago

zobac commented 1 year ago

Please first make sure you have looked at: OS: Windows 10 64 bit Python: 3.11.0

pip install pyodbc

Collecting pyodbc
  Using cached http://svn.ca.convergentmfg.com:4040/root/pypi/%2Bf/7ea/7869532b96b8d/pyodbc-4.0.34.tar.gz (271 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'pyodbc' extension
      creating build
      creating build\temp.win-amd64-cpython-311
      creating build\temp.win-amd64-cpython-311\Release
      creating build\temp.win-amd64-cpython-311\Release\src
      "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPYODBC_VERSION=4.0.34 -IE:\Envs\pyodbcTest\include -IC:\Python311\include -IC:\Python311\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 /Tpsrc\buffer.cpp /Fobuild\temp.win-amd64-cpython-311\Release\src\buffer.obj /Wall /wd4514 /wd4820 /wd4668 /wd4711 /wd4100 /wd4127 /wd4191 /d2FH4-
      buffer.cpp
      c:\python311\include\cpython/unicodeobject.h(423): warning C4365: '=': conversion from 'unsigned int' to 'int', signed/unsigned mismatch
      c:\python311\include\cpython/unicodeobject.h(450): warning C4365: '=': conversion from 'unsigned int' to 'int', signed/unsigned mismatch
      c:\python311\include\cpython/abstract.h(59): warning C4365: 'return': conversion from 'std::size_t' to 'Py_ssize_t', signed/unsigned mismatch
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(75): warning C4996: 'PyUnicode_FromUnicode': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(600): note: see declaration of 'PyUnicode_FromUnicode'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(86): warning C4996: 'PyUnicode_AS_UNICODE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(685): note: see declaration of 'PyUnicode_AS_UNICODE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(126): warning C4996: 'PyUnicode_GET_SIZE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(652): note: see declaration of 'PyUnicode_GET_SIZE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(146): warning C4996: 'PyUnicode_GET_SIZE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(652): note: see declaration of 'PyUnicode_GET_SIZE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(147): warning C4996: 'PyUnicode_AS_UNICODE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(685): note: see declaration of 'PyUnicode_AS_UNICODE'
      fatal error C1007: unrecognized flag '-FH4-' in 'p2'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyodbc
  Running setup.py clean for pyodbc
Failed to build pyodbc
Installing collected packages: pyodbc
  Running setup.py install for pyodbc ... error
  error: subprocess-exited-with-error

  × Running setup.py install for pyodbc did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      running install
      E:\Envs\pyodbcTest\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      building 'pyodbc' extension
      creating build
      creating build\temp.win-amd64-cpython-311
      creating build\temp.win-amd64-cpython-311\Release
      creating build\temp.win-amd64-cpython-311\Release\src
      "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPYODBC_VERSION=4.0.34 -IE:\Envs\pyodbcTest\include -IC:\Python311\include -IC:\Python311\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 /Tpsrc\buffer.cpp /Fobuild\temp.win-amd64-cpython-311\Release\src\buffer.obj /Wall /wd4514 /wd4820 /wd4668 /wd4711 /wd4100 /wd4127 /wd4191 /d2FH4-
      buffer.cpp
      c:\python311\include\cpython/unicodeobject.h(423): warning C4365: '=': conversion from 'unsigned int' to 'int', signed/unsigned mismatch
      c:\python311\include\cpython/unicodeobject.h(450): warning C4365: '=': conversion from 'unsigned int' to 'int', signed/unsigned mismatch
      c:\python311\include\cpython/abstract.h(59): warning C4365: 'return': conversion from 'std::size_t' to 'Py_ssize_t', signed/unsigned mismatch
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(75): warning C4996: 'PyUnicode_FromUnicode': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(600): note: see declaration of 'PyUnicode_FromUnicode'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(86): warning C4996: 'PyUnicode_AS_UNICODE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(685): note: see declaration of 'PyUnicode_AS_UNICODE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(126): warning C4996: 'PyUnicode_GET_SIZE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(652): note: see declaration of 'PyUnicode_GET_SIZE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(146): warning C4996: 'PyUnicode_GET_SIZE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(652): note: see declaration of 'PyUnicode_GET_SIZE'
      c:\users\guy\appdata\local\temp\pip-install-zr1skgw9\pyodbc_74ec003573f34a98941d5dd4119322b2\src\pyodbccompat.h(147): warning C4996: 'PyUnicode_AS_UNICODE': deprecated in 3.3
      c:\python311\include\cpython/unicodeobject.h(685): note: see declaration of 'PyUnicode_AS_UNICODE'
      fatal error C1007: unrecognized flag '-FH4-' in 'p2'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pyodbc

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
v-chojas commented 1 year ago

The FH4 option appeared only in VS 2019.

https://github.com/mkleehammer/pyodbc/blob/master/setup.py#L179

Looks like the option should only be added if the compiler version is new enough.

gordthompson commented 1 year ago

If you are having difficulty getting pyodbc to install from source on Windows you could try one of these unofficial wheels:

(Files removed. See below.)

SimoneD89 commented 1 year ago

AppVeyor deployed new Windows images with Python 3.11 support, see https://github.com/appveyor/ci/issues/3844. Therefore, it is in principle possible to use it to build win wheels for pyodbc (py3.11)

gordthompson commented 1 year ago

@SimoneD89 - #1115

scotscotmcc commented 1 year ago

The unofficial wheels given by GordThompson above cause an issue with creating sqlalchemy engines. sqlalchemy assumes that the version scheme is all integers, but the above version is 4.0.dev0, and so when creating an engine with sqlalchemy you get ValueError: invalid literal for int() with base 10: '' from where the regex fails to pull the third element from the version and so tries int('')

keitherskine commented 1 year ago

Yes @scotscotmcc , those wheels should not be labelled 4.0.dev0, even if they are unofficial. I'm working on a fix, shouldn't take too long. Watch this space.

keitherskine commented 1 year ago

Hopefully, PR #1121 should fix this. It may be possible for you to download the artifacts from the CI pipeline (look for the file called "wheels"). That zip file should contain installable Windows wheels.

scotscotmcc commented 1 year ago

@keitherskine, the wheel in that download you have above appears to work just fine. Thanks a bunch!

mkleehammer commented 1 year ago

Thanks to an amazing job by @keitherskine, new releases build official wheels now. There is an official 4.0.35 wheel available.