Python pip unable to locate pyodbc
Asked Answered
T

6

29

Using virtualenv and just trying to install pyodbc. All resources I can find claim this should be extremely straightforward. After all the basic installs of MySQL, etc., just do:

pip install pyodbc

However, I am seeing a very strange error. It has nothing (as far as I can tell) to do with missing libraries, and after Googling for this sort of error for a long time, I can't find anything constructive on it at all.

(local-dev)espears@espears-w ~ $ pip install pyodbc
Downloading/unpacking pyodbc
  Could not find any downloads that satisfy the requirement pyodbc
  Some externally hosted files were ignored (use --allow-external pyodbc to allow).
Cleaning up...
No distributions at all found for pyodbc
Storing debug log for failure in /home/espears/.pip/pip.log

So I tried with the "allow-external" option and it does not help:

(local-dev)espears@espears-w ~ $ pip install --allow-external pyodbc
You must give at least one requirement to install (see "pip help install")

But the help documentation makes it appear that I am using this option correctly, e.g. from the output of running pip help install:

Package Index Options:

...

  --allow-external <package>  Allow the installation of externally hosted files

Here's the result in the PIP log file:

(local-dev)espears@espears-w ~ $ cat /home/espears/.pip/pip.log
Downloading/unpacking pyodbc
  Getting page https://pypi.python.org/simple/pyodbc/
  URLs to search for versions for pyodbc:
  * https://pypi.python.org/simple/pyodbc/
  Analyzing links from page https://pypi.python.org/simple/pyodbc/
    Skipping link http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/); not a file
    Skipping link http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/); not a file
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Not searching http://code.google.com/p/pyodbc/downloads/list (from https://pypi.python.org/simple/pyodbc/) for files because external urls are disallowed.
  Could not find any downloads that satisfy the requirement pyodbc
  Some externally hosted files were ignored (use --allow-external pyodbc to allow).
Cleaning up...
  Removing temporary dir /home/espears/.virtualenvs/local-dev/build...
No distributions at all found for pyodbc
Exception information:
Traceback (most recent call last):
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/commands/install.py", line 270, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/req.py", line 1157, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/home/espears/.virtualenvs/local-dev/local/lib/python2.7/site-packages/pip/index.py", line 285, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for pyodbc

It makes it seem that if I can just get the --allow-external option to work, it will work because it clearly sees the common location for getting pyodbc.

But I am puzzled why this is needed at all, when virtually all references to installing pyodbc do not need to go out of the way to enable external links. I've also been installing many packages all day today, with few issues and certainly not encountering this allow-external need in any other case.

I am using pip version 1.5 with Python 2.7.3 on Ubuntu 12.04.

Tabulator answered 10/1, 2014 at 21:23 Comment(3)
Any extra information in /home/espears/.pip/pip.log?Bragdon
Also, what version of pip?Bragdon
I'm setting up two virtualenvs, Py 2.6.9 and Py 2.7.5. It installs fine in the 2.6.9 venv (with the --allow-external and --allow-unverified flags), but not in the 2.7.5 venv. Weird, right? In the 2.7.5 venv I have to download via URL. (AWS CentOS) I have no_clue why this should be... (pip v 1.5.6)Hughmanick
B
45

Running pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc will work if the PyPI directory structure is correct.

Based on the pip.log output when I originally posted this answer, I think that package's website directory structure was broken. You can always work around this type of problem by specifying the URL of the package like pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip, links for different versions are described here.

Bragdon answered 10/1, 2014 at 21:59 Comment(4)
Excellent. I completely forgot that I could use the URL directly.Tabulator
--allow-all-external disables the security. See other answers and correctly use --allow-external.Awfully
Not working on Windows 8.1: building 'pyodbc' extension error: Unable to find vcvarsall.bat Workaround: pypyodbc or binary installer for old Python 3.3Poriferous
These command line options don't work anymore, at least on Amazon Linux 4.14.225-168.357.amzn2.x86_64: DEPRECATION: --allow-external has been deprecated and will be removed in the future. Due to changes in the repository protocol, it no longer has any effect. and subsequently fails with Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/pyodbc/, and finally: Could not find a version that satisfies the requirement pyodbc (from versions: ) No matching distribution found for pyodbcLorca
O
10

I just tried installing pyodbc as well and hit the same wall. I think the problem you and I both hit is that --allow-external consumes the next argument as well. So you actually need to write:

sudo pip install --allow-external pyodbc pyodbc

I then hit another error about unverified sources so that command that actually worked for me was:

sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc

Note that once that was done the permissions on the installed files prevented normal users from access pyodbc. So I went in manually adjusted the permissions on all installed packages (seemed easier than finding just the files needed by pyodbc).

cd /usr/local/lib/python2.7/
chmod -R o=g dist-packages

As per the suggestion of EMS I have added an issue to the Pip bug tracker. It can be found at:

https://github.com/pypa/pip/issues/1893

Orthodontics answered 24/6, 2014 at 1:50 Comment(2)
Thanks for documenting this. You might also file an issue at the pip project page. I don't think it is intended to consume extra arguments like that.Tabulator
@EMS you are welcome. I might do that because at the very least their help message definitely needs improving.Orthodontics
L
5

FWIW, on ms windows anything other than installing the binary (windows install) for me was cumbersome in a windows/cygwin hybrid environment.

I opted to use pypyodbc as it's pure python and didn't require any changes for my windows/linux development. It can be seen as an almost drop-in replacement for pyodbc with no compilation needed, and of course can be installed easily with pip install pypyodbc.

Ljoka answered 27/8, 2014 at 14:29 Comment(0)
H
4

There is an "easier" way to install pyodbc on windows in a virualenv using easy_install:

  • download latest pyodbc installer for windows
  • activate your virtualenv
  • easy_install pyodbc-3.0.7.win32-py2.7.exe

as used for pywin32 see: How can I use pywin32 with a virtualenv without having to include the host environment's site-packages folder?

Honegger answered 7/9, 2014 at 14:2 Comment(1)
I've found this to be the easiest method of installing any package that pip has trouble with. I initially found it when trying to install numpy & scipy, and have had success with every package I've tried since then.Davit
A
3

I had success when installed with

sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc

However, I also needed the unixodbc-dev package in order for pyodbc to actually compile.

Attendant answered 12/3, 2015 at 13:5 Comment(1)
I couldn't install pyodbc on Ubunt 16.04 because of error: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1. These set of commands solved my issue: sudo apt-get install unixodbc-dev && sudo pip install pyodbc. Thx for mention unixodbc-dev!Dilettante
A
1

Both --allow-unverified and --allow-external take package name as an argument.

From pip help install:
--allow-external <package>   Allow the installation of a package even if it
                             is externally hosted
--allow-unverified <package> Allow the installation of a package even if it 
                             is hosted in an insecure and unverifiable way
  • --allow-external requires an argument (name of th external to allow).
  • Same goes for --allow-unverified too .
  • With pip install --allow-external pyodbc, you are allowing the external called pyodbc
  • pip install --allow-external pyodbc pydodbc is what you need, first pyodbc allows that external, second one actually tells pip which package to install.

    From pip help install: --allow-external Allow the installation of a package even if it is externally hosted --allow-unverified Allow the installation of a package even if it is hosted in an insecure and unverifiable way

So your usage should be

pip install <pkg> --allow-unverified <pkg> --allow-external <pkg>

or the little confusing:

pip install --allow-unverified <pkg> --allow-external <pkg> <pkg>

DO NOT use --allow-all-external when you just want to allow one and not ALL. It kills the whole purpose of putting in the security check.

Awfully answered 20/3, 2015 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.