how to install pyodbc module

Posted by guthrie on 2010-05-11 04:47

I just upgraded from XP-32 to W7-64, and reinstalled Active Python (2.6). I have been using pyodbc library on my XP system, and now am trying to reinstall it.

I get errors - from pypm:
"E:\Plang\ActiveState\Python\Scripts>pypm install pyodbc
Get: [pypm-be.activestate.com] :repository-index:
Get: [pypm-free.activestate.com] :repository-index:
autosync: synced 2 repositories
The following packages will be installed:
pyodbc-2.1.7-1
Get: [pypm-be.activestate.com] pyodbc 2.1.7-1
error: Can't install pyodbc-2.1.7: requires Business Edition subscription"

(?? Packages repository access is supposed to be available in community edition)

From easy_install:
Searching for pyodbc
Reading http://pypi.python.org/simple/pyodbc/
Reading http://pyodbc.sourceforge.net
Reading http://code.google.com/p/pyodbc
Reading http://code.google.com/p/pyodbc/downloads/list
Reading https://sourceforge.net/project/showfiles.php?group_id=162557
Best match: pyodbc 2.1.7
Downloading http://pyodbc.googlecode.com/files/pyodbc-2.1.7.zip
Processing pyodbc-2.1.7.zip
Running pyodbc-2.1.7\setup.py -q bdist_egg --dist-dir c:\users\guthrie\appdata\local\temp\easy_install-kbz_s8\pyodbc-2.1.7\egg-dist-tmp-jd6owa
no previously-included directories found matching 'web\*.cmd'
no previously-included directories found matching 'setup.PY'
error: Setup script exited with error: Unable to find vcvarsall.bat

How do I get back to an installed pyodbc?
I can find the package on the net, but couldn't convince any tool to install it manually!

sridharr
ActiveState Staff
Tue, 2010-05-11 08:41

The 64-bit repository for Windows, unlike its 32-bit counterpart, is not free ... and requires Business Edition. You can try the ActivePython 32-bit installer instead (and that uses the free 32-bit repository). It will work just fine on a 64-bit OS.

guthrie | Tue, 2010-05-11 08:51

Thanks. So much for converting to 64 bits as an advantage!
Can you point me to some details on how to do this?

Perhaps I can just run the 32-bit version of python on my 64-bit system?

But it would also seem that even if ActiveState doesn't want to serve me from their repository, there should be some way to access regular public Python module repositories - yes?

Would I need to install a full 32-bit Python install? Then if I ran it's pypm, would it install into its lib directory, and then I would just copy?

I tried to copy the lib/pyodbc... files from a 32-bit machine into my lib directory, but from Komodo it still was not recognized (no errors, just reports "no pyodbc module found").

I copied the .egg files form my 32-bit system but didn't know how to install them. Both pypm and easy_install went to the web, and then failed.

sridharr
ActiveState Staff
Tue, 2010-05-11 09:00

Can you point me to some details on how to do this? Perhaps I can just run the 32-bit version of python on my 64-bit system?

Yes. Here's solution #1

a) Uninstall ActivePython 2.6 64-bit
b) Install ActivePython 2.6 32-bit from http://downloads.activestate.com/ActivePython/releases/2.6.5.12/ActivePy...
c) Open a command prompt and type "pypm install pyodbc"
d) Type "pypm files pyodbc" to verify where the files installed

But it would also seem that even if ActiveState doesn't want to serve me from their repository, there should be some way to access regular public Python module repositories - yes?

We do serve a 64-bit repository, but it is not free. If you must absolutely stick to the 64-bit version, here's solution #2:

a) Buy Business Edition

OR

a) Install Visual Studio 2008 (apparently the free Express edition won't work - http://goo.gl/SMqH )
b) Type "easy_install pyodbc" or "pip install pyodbc" ... which should now work.

I tried to copy the lib/pyodbc... files from a 32-bit machine into my lib directory
I copied the .egg files form my 32-bit system

No! You shouldn't mix binaries from 32-bit to 64-bit (or vice versa). It won't work.

guthrie | Tue, 2010-05-11 10:59

Thanks.
I'll revert to a 32-bit install, that seems simplest.

I do have Studio 2010 installed, shouldn't that work (have worked)?
(It failed with the above messages.)

I understand about your 64-bit repository; I was asking a slightly different question - how to install from another repository. I am not so Python conversant, but Perl & Linux & ... all have many open free repositories, like pypi for example? How would I install modules from them to AS-Python?

I see what looks like something for this on Linux (pypi-install), but I don't think it installs to AS-Python (although it is announced on ASPN).

Thanks for your note and information.

sridharr
ActiveState Staff
Tue, 2010-05-11 11:16

I do have Studio 2010 installed, shouldn't that work (have worked)?

I can tell you that on our Windows 64-bit build machine, we have Visual Studio 2008 professional (*with* x64 support -- which is not selected *by default* in the installer) installed, and pyodbc compiles just fine.

If you did all that, i.e. included x64 support when installing VS, then distutils-sig@python.org is an appropriate place to discuss this issue further (distutils, the underlying component in Python that is used for packaging, building and installation, is known to have a few bugs in VS installation detection).

how to install from another repository. I am not so Python conversant, but Perl & Linux & ... all have many open free repositories, like pypi for example? How would I install modules from them to AS-Python?

Just like you do with any other CPython distribution. Though not as reliable/simple as CPAN/apt-get/rpm, Python has easy_install, which is now getting superseded by pip. Both easy_install and pip are included with ActivePython. So you either type "easy_install pyodbc" or "pip install pyodbc" when, for some reason, you cannot install that same package with PyPM. Checkout this guide for the fine details -http://guide.python-distribute.org/

With both pip and easy_install you should be able to install any package that is registered properly in pypi.python.org (PyPM too uses this site, in addition to manually configured/patched packages).

I see what looks like something for this on Linux (pypi-install), but I don't think it installs to AS-Python (although it is announced on ASPN).

pypi-install is an utility script that is part of the (Linux-only) stdeb package, which can be installed to ActivePython using "pypm install stdeb" ... though pip is the recommended source-based install tool of choice in the Python community.

guthrie | Tue, 2010-05-11 12:55

Many thanks.

guthrie | Tue, 2010-05-11 16:55

Thanks, I reverted to 32-bit Python 2.6, and first tried pip - which failed in a manner similar to what easy_install had. Both report the error:
error: Unable to find vcvarsall.bat
Seems like it is a VStudio/VC issue, and 2010 and 2008 may not behave the same, since I have '10 and you report that '08 works fine.

Then I tried pypm, and it worked fine.
------------------
E:\Plang\ActivePython\Scripts>pip pyodbc
Usage: pip-script.py COMMAND [OPTIONS]

pip-script.py: error: No command by the name pip-script.py pyodbc
(maybe you meant "pip-script.py install pyodbc")

E:\Plang\ActivePython\Scripts>pip install pyodbc
Downloading/unpacking pyodbc
Downloading pyodbc-2.1.7.zip (148Kb): 148Kb downloaded
Running setup.py egg_info for package pyodbc
no previously-included directories found matching 'web\*.cmd'
no previously-included directories found matching 'setup.PY'
Installing collected packages: pyodbc
Running setup.py install for pyodbc
building 'pyodbc' extension
error: Unable to find vcvarsall.bat
Complete output from command E:\Plang\ActivePython\python26.exe -c "import s
etuptools; __file__='E:\\Plang\\ActivePython\\Scripts\\build\\pyodbc\\setup.py';
execfile('E:\\Plang\\ActivePython\\Scripts\\build\\pyodbc\\setup.py')" install
--single-version-externally-managed --record c:\users\guthrie\appdata\local\temp
\pip-7wens_-record\install-record.txt --install-headers E:\Plang\ActivePython\Sc
ripts\lib\include:
running install

running build

running build_ext

building 'pyodbc' extension

error: Unable to find vcvarsall.bat

----------------------------------------
Command E:\Plang\ActivePython\python26.exe -c "import setuptools; __file__='E:\\
Plang\\ActivePython\\Scripts\\build\\pyodbc\\setup.py'; execfile('E:\\Plang\\Act
ivePython\\Scripts\\build\\pyodbc\\setup.py')" install --single-version-external
ly-managed --record c:\users\guthrie\appdata\local\temp\pip-7wens_-record\instal
l-record.txt --install-headers E:\Plang\ActivePython\Scripts\lib\include failed
with error code 1
Storing complete log in ./pip-log.txt

sridharr
ActiveState Staff
Tue, 2010-05-11 17:10

Why would you try to use pip, when the pyodbc binary package is available free of charge from the 32-bit ActiveState repository?

Type "pypm install pyodbc".

As a rule of thumb, always try to install a package with PyPM first and only if that fails, try pip or easy_install.

guthrie | Tue, 2010-05-11 19:38

I was just trying it to see if it *would* work in this configuration.

In some cases as you note, it might be useful.

And no, it didn't! And I was basically noting that it seemed to fail in the same way as easy_install, some VS problem.

Anyway, all done (for now), thanks.

guthrie | Sat, 2010-09-25 07:59

Subsequently I found that after a conversion to W7 and Python 2.7, pyodbc is no longer available without BE ($999) subscription.

>pypm install pyodbc
> > The following
> > packages will be installed to ~\AppData\Roaming\Python (2.7):
> > pyodbc-2.1.8-1
> > Get: [pypm-be.activestate.com] pyodbc 2.1.8-1
> > error: Can't install pyodbc-2.1.8: requires Business Edition
> > subscription

> You must have installed pyodbc during the initial introduction period for PyPM. A small number
> of modules which were freely available during the introduction were added to the Business
> Edition only list. Even with 32-bit ActivePython, pyodbc is only available with a Business
> Edition license.