Failed building wheel for pyodbc

See original GitHub issue

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:

  • Python: 3.8.6
  • pyodbc: 4.0.32
  • OS: Red Hat Enterprise Linux Server release 7.9

i try to install pyodbc via pip pip install pyodbc and i got this error

Looking in indexes: https://analytics-rspm.hosting.corp/Pypi/latest/simple
Collecting pyodbc
  Downloading https://analytics-rspm.hosting.corp/Pypi/latest/packages/9be5f0c3590655e1968488410fe3528bb8023d527e7ccec1f663d64245071a6b/pyodbc-4.0.32.tar.gz (280 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 280.0/280.0 kB 2.0 MB/s eta 0:00:00a 0:00:01
  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
  ╰─> [14 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'pyodbc' extension
      creating build
      creating build/temp.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/src
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=4.0.32 -I/opt/pyvenv/py38-venv/include -I/opt/rh/rh-python38/root/usr/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-cpython-38/src/buffer.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include
      In file included from src/buffer.cpp:12:0:
      src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
       #include <Python.h>
                          ^
      compilation terminated.
      error: command '/usr/bin/gcc' 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
  ╰─> [16 lines of output]
      running install
      /opt/pyvenv/py38-venv/lib64/python3.8/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.linux-x86_64-cpython-38
      creating build/temp.linux-x86_64-cpython-38/src
      gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=4.0.32 -I/opt/pyvenv/py38-venv/include -I/opt/rh/rh-python38/root/usr/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-cpython-38/src/buffer.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include
      In file included from src/buffer.cpp:12:0:
      src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
       #include <Python.h>
                          ^
      compilation terminated.
      error: command '/usr/bin/gcc' 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.
Note: you may need to restart the kernel to use updated packages.


```i tried to install this dependencies but  doesnt slove it : 
unixODBC
unixodbc-dev
gcc-c++

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
gregholstcommented, Jul 12, 2022

Had the same issue, but with Python 3.9 and running on Ubuntu 20.04. Maybe installing unixodbc-dev:

sudo apt install unixodbc-dev

helps for you as well. See here: https://stackoverflow.com/questions/71383153/pyodbc-legacy-install-failure-in-ubuntu-python-3-9/72935800#72935800

1reaction
mkleehammercommented, Nov 16, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip install pyodbc failed ERROR: Failed building wheel for ...
You can try the following: !apt install unixodbc-dev !pip install pyodbc.
Read more >
pyodbc installation issue in jupyter lab - Google Groups
Try to install libiodbc2-dev first. You are missing the sql.h which is provided by that package.
Read more >
Unable to install pyodbc failed ERROR - CodersCaffe
Unable to install pyodbc failed ERROR: Failed building wheel for pyodbc package errors solving.
Read more >
pyodbc - PyPI
Precompiled binary wheels are provided for most Python versions on Windows and macOS. On other operating systems this will build from source. Note,...
Read more >
How come I can't install pyodbc to my virtual environment in ...
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyodbc. Running setup.py ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found