Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyodbc install does not support python 3.5.1

I am trying to install pyodbc for a specific project, but unfortunately when I try to do an install, no matter the command I end up with the following error:

Command "/usr/local/bin/python3.5 -u -c "import setuptools,
tokenize;__file__='/tmp/pip-build-vw5rz5_t/pyodbc/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read()
.replace('\r\n', '\n'), __file__, 'exec'))" install --record
/tmp/pip-p5vfq2hq-record/install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in 
/tmp/pip-build-vw5rz5_t/pyodbc/

Obviously, this error has already been reported here, and I am fully aware this is a python version dependency error. However I have attempted many different approaches to deal with this issue, including all the attempts in the Stack Overflow question, and the following:

  • Original attempt:

    sudo pip3 install pyodbc
    
  • Installing in virtualenv (see here, and here)

Could anyone point me the correct way to install a python package that has a dependency on another python version than the default python package? I have another project that runs on python3.5 so I would prefer if I could do an install in the virtualenv.

Thanks for your help!

like image 750
Philippe Hebert Avatar asked Apr 21 '16 20:04

Philippe Hebert


2 Answers

Following marctrem's excellent answer, and the clues left by Philippe Hebert, one can easily install unixodbc with debian distributions using:

sudo apt-get install unixodbc-dev
sudo apt-get install unixodbc-bin

With these dependencies installed, the following works like a charm:

pip3 install pyodbc
like image 89
lunar_primate Avatar answered Oct 23 '22 10:10

lunar_primate


This should work.

Clone, build and install!

$ git clone https://github.com/mkleehammer/pyodbc.git
$ python3 setup.py build
# python3 setup.py install

You might need unixodbc since it's a pyodbc dependency.

Have fun!

like image 34
marctrem Avatar answered Oct 23 '22 09:10

marctrem