JPC
JPC

Reputation: 5173

How to install pyodbc to be used in ipython

I'm confused. I have installed pyodbc on my computer and I was able to import it using other IDE but i'm new to ipython.

I use Ananconda , and was able to install other library using something like

pip install BeautifulSoup

But when I do that with pyodbc using

pip install pyodbc

I got error :

error: command 'gcc' failed with exist status 1

C:\Users\jeannie.chirayu>pip install pyodbc Downloading/unpacking pyodbc You are installing a potentially insecure and unverifiable file. Future versio ns of pip will default to disallowing insecure files. Downloading pyodbc-3.0.7.zip (85kB): 85kB downloaded Running setup.py egg_info for package pyodbc

warning: no files found matching 'tests\*'

Installing collected packages: pyodbc Running setup.py install for pyodbc building 'pyodbc' extension C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC:\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\t emp\pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\app data\local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4 820 /wd4711 /wd4100 /wd4127 /wd4191 gcc.exe: error: /Wall: No such file or directory gcc.exe: error: /wd4668: No such file or directory gcc.exe: error: /wd4820: No such file or directory gcc.exe: error: /wd4711: No such file or directory gcc.exe: error: /wd4100: No such file or directory gcc.exe: error: /wd4127: No such file or directory gcc.exe: error: /wd4191: No such file or directory error: command 'gcc' failed with exit status 1 Complete output from command C:\Anaconda\python.exe -c "import setuptools;__ file__='c:\users\jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu \pyodbc\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), __ file__, 'exec'))" install --record c:\users\jeanni~1.chi\appdata\local\temp\pip- lqnyba-record\install-record.txt --single-version-externally-managed: running install

running build

running build_ext

building 'pyodbc' extension

C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC :\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\temp\ pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\appdata \local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4820 /wd4711 /wd4100 /wd4127 /wd4191

gcc.exe: error: /Wall: No such file or directory

gcc.exe: error: /wd4668: No such file or directory

gcc.exe: error: /wd4820: No such file or directory

gcc.exe: error: /wd4711: No such file or directory

gcc.exe: error: /wd4100: No such file or directory

gcc.exe: error: /wd4127: No such file or directory

gcc.exe: error: /wd4191: No such file or directory

error: command 'gcc' failed with exit status 1


Cleaning up... Command C:\Anaconda\python.exe -c "import setuptools;file='c:\users\jeanni ~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc\setup.py';exec( compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\jeanni~1.chi\appdata\local\temp\pip-lqnyba-record\install-rec ord.txt --single-version-externally-managed failed with error code 1 in c:\users \jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc Storing complete log in C:\Users\j\pip\pip.log

Any recommendation would help. Thanks.

Upvotes: 1

Views: 4866

Answers (2)

acushner
acushner

Reputation: 9946

this was annoying. but i got it working. basically, pyodbc source code is missing a lot of crap.

1) in the pyodbc directory, open setup.py and search for "wd4668".

change that list to look like this:

settings['extra_compile_args'] = []

2) in the src directory, create a file called "abc_minmax.h". in it, put:

#ifndef min 

#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a > b) ? a : b)

#endif

3) in the following files in the src directory:

cursor.h
params.h
sqlwchar.h

add the following line near the other includes at the top:

#include "abc_minmax.h"

4) finally, in the file wrapper.h, add the following 2 lines near the other includes:

#include <Windows.h>
#include <Winreg.h>

ok, that should do it! let me know if something doesn't work.

Upvotes: 2

bevanj
bevanj

Reputation: 254

It won't help with the pip install issues but you could download the .exes from https://code.google.com/p/pyodbc/ or http://www.lfd.uci.edu/~gohlke/pythonlibs/

Upvotes: 0

Related Questions