Python pip无法找到pyodbc

ely*_*ely 29 python pip pyodbc

使用virtualenv并尝试安装pyodbc.我能找到的所有资源都声称这应该非常简单.在完成MySQL等的所有基本安装之后,只需执行以下操作:

pip install pyodbc
Run Code Online (Sandbox Code Playgroud)

但是,我看到一个非常奇怪的错误.它没有(据我所知)与丢失的库有关,并且在谷歌搜索这种错误很长一段时间之后,我根本找不到任何有建设性的东西.

(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
Run Code Online (Sandbox Code Playgroud)

所以我尝试使用"allow-external"选项,它没有帮助:

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

但帮助文档使我看起来正确使用此选项,例如从运行的输出pip help install:

Package Index Options:

...

  --allow-external <package>  Allow the installation of externally hosted files
Run Code Online (Sandbox Code Playgroud)

这是PIP日志文件中的结果:

(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
Run Code Online (Sandbox Code Playgroud)

它似乎如果我可以让--allow-external选项工作,它将工作,因为它清楚地看到了获取pyodbc的常见位置.

但是我很困惑为什么要这样做,几乎所有对安装pyodbc的引用都不需要为了启用外部链接.我今天也一直在安装很多软件包,几乎没有问题,allow-external在任何其他情况下都不会遇到这种需求.

我在Ubuntu 12.04上使用pip version 1.5和Python 2.7.3.

sho*_*app 44

pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc如果PyPI目录结构正确,则运行将起作用.

根据我最初发布此答案时的pip.log输出,我认为该软件包的网站目录结构已被破坏.您可以通过指定包的URL来解决此类问题,例如pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip,此处描述了不同版本的链接.


Bow*_*ens 10

我刚刚尝试安装pyodbc并打到同一堵墙.我认为你和我所遇到的问题是--allow-external也会消耗下一个参数.所以你实际上需要写:

sudo pip install --allow-external pyodbc pyodbc
Run Code Online (Sandbox Code Playgroud)

然后我点击了另一个关于未经验证的来源的错误,以便实际对我有用的命令是:

sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
Run Code Online (Sandbox Code Playgroud)

请注意,完成后,已安装文件的权限会阻止普通用户访问pyodbc.所以我手动调整了所有已安装软件包的权限(看起来比查找pyodbc所需的文件更容易).

cd /usr/local/lib/python2.7/
chmod -R o=g dist-packages
Run Code Online (Sandbox Code Playgroud)

根据EMS的建议,我向Pip bug跟踪器添加了一个问题.它可以在以下位置找到:

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


joe*_*mct 5

FWIW,在ms窗口上,除了为我安装二进制文件(windows install)之外的任何东西在windows/cygwin混合环境中都很麻烦.

我选择使用pypyodbc 作为纯Python,并且不需要对我的windows/linux开发进行任何更改.它可以被视为pyodbc几乎无需替换,无需编译,当然可以轻松安装pip install pypyodbc.