pip install pyodbc failed ERROR: Failed building wheel for pyodbc
Asked Answered
R

4

18

I'am trying to import pyodbc library into google colab, but i'am getting this error.

Just in case, I have Anaconda installed in my notebook, and I never had problem with pyodbc in there.

Can you help me please?

Tks!

Collecting pyodbc
  Using cached https://files.pythonhosted.org/packages/81/0d/bb08bb16c97765244791c73e49de9fd4c24bb3ef00313aed82e5640dee5d/pyodbc-4.0.30.tar.gz
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (setup.py) ... error
  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: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-u5dmb223/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-u5dmb223/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-record-9jmhckrt/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Representation answered 20/10, 2020 at 17:2 Comment(8)
Have you checked the logs at /tmp/pip-record-9jmhckrt/install-record.txt?Ballou
Hi, i'm sorry, but I don't know how to do that.. Can you tell me please?Representation
You could run cat /tmp/pip-record-9jmhckrt/install-record.txt in the terminal or print(open("/tmp/pip-record-9jmhckrt/install-record.txt").read()) in PythonBallou
Tks a lot for your help, but I didn't find this file in my directory. When I run in jupyter notebook, i get the same error. FileNotFoundError Traceback (most recent call last) <ipython-input-31-cd02d5e61a23> in <module>() ----> 1 print(open("/tmp/pip-record-9jmhckrt/install-record.txt").read()) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-record-9jmhckrt/install-record.txt'Representation
It's a temporary directory, so files in there can be automatically deleted at any time. Try running the installation again, copy the file path from the error message and run cat that/file/pathBallou
Wait, it's meant to be run on Google Colab, not your Windows machine. Also check the documentation of Colab - maybe they don't allow the installation of compiled modules.Ballou
Hi guys! It's solved. I installed "!apt install unixodbc-dev" first, then I called "pip install pyodbc" and it worked very well.Representation
Answered the question in the below post. Check it out https://mcmap.net/q/410159/-how-to-properly-install-pyodbc-and-drivers-on-m1-macGroin
H
58

You can try the following:

!apt install unixodbc-dev
!pip install pyodbc
Harman answered 21/10, 2020 at 2:30 Comment(1)
Not working same error though tried install unixodbc instead of unixodbc as in MacOS installing through brew .Groin
C
9

While installing 'unixodbc-dev' it will ask for permission to install all dependent required libraries. Follow the steps to install pyodbc:

!apt install unixodbc-dev --yes
!pip install pyodbc
Cogent answered 21/1, 2022 at 4:28 Comment(0)
C
2

Follow this one:

!apt install unixodbc-dev --yes
!pip install pyodbc

Giving permission while installing unixodbc-dev to install if anything required.

Cogent answered 12/1, 2022 at 9:45 Comment(0)
J
2

In case if needed to be installed in the container, then here are the lines which worked for me. Add these in the beginning in DockerFile

USER root
RUN apt-get update && apt-get install build-essential unixodbc-dev -y
RUN pip install pyodbc
Janettejaneva answered 30/8, 2022 at 15:14 Comment(1)
Exactly what I needed in my case. Thanks!Southwester

© 2022 - 2024 — McMap. All rights reserved.