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

pip install pyodbc failing: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 #276

Closed
wondernath opened this issue Aug 31, 2017 · 16 comments

Comments

@wondernath
Copy link

@wondernath wondernath commented Aug 31, 2017

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: 2.7.6
  • pyodbc: Latest version
  • OS: ubuntu 14.04.5
  • DB:
  • driver:

Issue

pip install pyodbc --user
Collecting pyodbc
Using cached pyodbc-4.0.17.tar.gz
Building wheels for collected packages: pyodbc
Running setup.py bdist_wheel for pyodbc ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-YtLrrj/pyodbc/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 /tmp/tmp5eqhA5pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.17 -DSQL_WCHART_CONVERT=1 -I/usr/include/python2.7 -c src/textenc.cpp -o build/temp.linux-x86_64-2.7/src/textenc.o -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from src/textenc.cpp:2:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


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
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-YtLrrj/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-CRLrEJ-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.17 -DSQL_WCHART_CONVERT=1 -I/usr/include/python2.7 -c src/textenc.cpp -o build/temp.linux-x86_64-2.7/src/textenc.o -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from src/textenc.cpp:2:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-YtLrrj/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-CRLrEJ-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-YtLrrj/pyodbc/

@gordthompson

This comment has been minimized.

Copy link
Contributor

@gordthompson gordthompson commented Sep 1, 2017

src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^

Your machine does not have the ODBC header files installed. You need to do

sudo apt-get install unixodbc-dev

and then try installing pyodbc again.

@kabirbaidhya

This comment has been minimized.

Copy link

@kabirbaidhya kabirbaidhya commented Feb 26, 2018

Hi,

I already have unixodbc-dev installed on my system. I followed this.

➜ sudo apt-get install unixodbc-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
unixodbc-dev is already the newest version (2.3.1-4.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And I'm trying to install the latest pyodbc==4.0.22; still getting the same error. Any idea on this?

➜ pip install pyodbc==4.0.22                                                                                                      
Collecting pyodbc==4.0.22
  Using cached pyodbc-4.0.22.tar.gz
Building wheels for collected packages: pyodbc
  Running setup.py bdist_wheel for pyodbc ... error
  Complete output from command /home/kabir/envs/etl/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kp3jjwpo/pyodbc/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 /tmp/tmpqpqsm7h7pip-wheel- --python-tag cp35:
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.22 -I/usr/include/python3.5m -I/home/kabir/envs/etl/include/python3.5m -c src/buffer.cpp -o build/temp.linux-x86_64-3.5/src/buffer.o -Wno-write-strings
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from src/buffer.cpp:12:0:
  src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  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
    Complete output from command /home/kabir/envs/etl/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kp3jjwpo/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-4setzddr-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kabir/envs/etl/include/site/python3.5/pyodbc:
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build/temp.linux-x86_64-3.5
    creating build/temp.linux-x86_64-3.5/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.22 -I/usr/include/python3.5m -I/home/kabir/envs/etl/include/python3.5m -c src/buffer.cpp -o build/temp.linux-x86_64-3.5/src/buffer.o -Wno-write-strings
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from src/buffer.cpp:12:0:
    src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/kabir/envs/etl/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-kp3jjwpo/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-4setzddr-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kabir/envs/etl/include/site/python3.5/pyodbc" failed with error code 1 in /tmp/pip-build-kp3jjwpo/pyodbc/

I'm using:

  • Python 3.5.2
  • Ms SQL Server 2017
  • Ubuntu 16.04 LTS

Let me know if I need to install any other dependencies.

@kabirbaidhya

This comment has been minimized.

Copy link

@kabirbaidhya kabirbaidhya commented Feb 26, 2018

Anyway, I figured out the issue. I had to install python3-dev on ubuntu (in addition to unixodbc-dev) and it did work.

In case anybody runs into this issue again. Please ensure you've installed these:

➜ sudo apt-get install python3-dev
➜ sudo apt-get install unixodbc-dev

FYI: Python 2.x users, will need python-dev instead.

@neostorm

This comment has been minimized.

Copy link

@neostorm neostorm commented Mar 1, 2018

I'm see the same issue and both python3-dev and unixodbc-dev are installed.
I've looked elsewhere and installed every recommended package any other thoughts on how to fix this?

Python 3.6.4
Ubuntu 16.04.2 LTS

    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from src/row.cpp:12:0:
    src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
@kabirbaidhya

This comment has been minimized.

Copy link

@kabirbaidhya kabirbaidhya commented Mar 2, 2018

Strange. I exactly had same issue.

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.22 -I/usr/include/python3.5m -I/home/kabir/envs/etl/include/python3.5m -c src/buffer.cpp -o build/temp.linux-x86_64-3.5/src/buffer.o -Wno-write-strings
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from src/buffer.cpp:12:0:
    src/pyodbc.h:45:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

But after installing python3-dev and unixodbc-dev, it got resolved.

Can you make sure you have all these dev packages installed on your system? Not sure if this works, but these include pretty much all the dependencies usually required for python.

➜ sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
➜ sudo apt-get install unixodbc-dev
@gordthompson

This comment has been minimized.

Copy link
Contributor

@gordthompson gordthompson commented Mar 2, 2018

@neostorm - How did you install Python 3.6 on that machine?

@carlosmarin

This comment has been minimized.

Copy link

@carlosmarin carlosmarin commented Apr 2, 2018

RHEL / CentOS:

yum install unixODBC
yum install unixODBC-devel
@ikwijaya

This comment has been minimized.

Copy link

@ikwijaya ikwijaya commented Sep 25, 2018

using alpine??

@ffedoroff

This comment has been minimized.

Copy link

@ffedoroff ffedoroff commented Mar 26, 2019

for python3.7 run also:
sudo apt-get install python3.7-dev

@luissamano

This comment has been minimized.

Copy link

@luissamano luissamano commented Apr 6, 2019

for python3.7 run also:
sudo apt-get install python3.7-dev

Thanks, It worked.

@dxkaufman

This comment has been minimized.

Copy link

@dxkaufman dxkaufman commented Apr 24, 2019

I have the same issue in Visual Studio Code on Mac OSX while trying to deploy a timer trigger function to Azure Functions. The function works perfectly while executing within VSC, but the deployment fails with the same 'unable to execute gcc' error. I found another issue talking about that, where I've asked for help too, but if anyone watching this issue can help me, I'd be very grateful!

@v-chojas

This comment has been minimized.

Copy link
Contributor

@v-chojas v-chojas commented Apr 24, 2019

@dxkaufman what you're describing has nothing to do with pyODBC, and that error message is very generic, so it is no surprise you will find issues about it which are completely unrelated to your situation.

@dxkaufman

This comment has been minimized.

Copy link

@dxkaufman dxkaufman commented Apr 24, 2019

@v-chojas For that matter, I seem to have read this post inattentively... I thought it mentioned the gcc error, but now I realize this one has more to do with the presence of code files... my mistake. Thanks for the quick reply.

@rskelley9

This comment has been minimized.

Copy link

@rskelley9 rskelley9 commented May 2, 2019

Might just come down to the version of Python one is using. I was using python 3.6 on ubuntu 14.04, so

sudo apt-get install python3.6-dev
sudo apt-get install unixodbc-dev
python3.6 -m pip install pyodbc

Worked for me.

@sumitkarn

This comment has been minimized.

Copy link

@sumitkarn sumitkarn commented Sep 19, 2019

worked for me on ubuntu 14.04. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.