使用virtualenv并尝试安装pyodbc。我能找到的所有资源都声称这应该非常简单。在完成MySQL的所有基本安装之后,只需执行:
pip install pyodbc
然而,我看到一个非常奇怪的错误。它没有(据我所知)与丢失的库有关,并且在谷歌搜索这种错误很长一段时间之后,我根本找不到任何有建设性的东西。
(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
所以我尝试使用“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")
但帮助文档显示我正确使用此选项,例如从运行pip help install
的输出:
Package Index Options:
...
--allow-external <package> Allow the installation of externally hosted files
以下是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
看起来如果我可以让--allow-external
选项工作,它会起作用,因为它清楚地看到了获取pyodbc的常用位置。
但是我很困惑为什么要这样做,几乎所有对安装pyodbc的引用都不需要为了启用外部链接。我今天整天都在安装很多软件包,几乎没有问题,在任何其他情况下都不会遇到allow-external
这个问题。
我在Ubuntu 12.04上使用pip version 1.5和Python 2.7.3。
答案 0 :(得分:44)
如果PyPI目录结构正确,则运行pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
将起作用。
基于我最初发布此答案时的pip.log输出,我认为该软件包的网站目录结构已被破坏。您始终可以通过指定pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip
等软件包的URL来解决此类问题,并在here中说明不同版本的链接。
答案 1 :(得分:10)
我刚尝试安装pyodbc并撞到同一堵墙。我认为你和我所遇到的问题是--allow-external也会消耗下一个参数。所以你实际上需要写:
sudo pip install --allow-external pyodbc pyodbc
然后我点击了另一个关于未验证来源的错误,以便实际对我有用的命令是:
sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
请注意,完成后,已安装文件的权限会阻止普通用户访问pyodbc。所以我手动调整了所有已安装软件包的权限(看起来比找到pyodbc所需的文件更容易)。
cd /usr/local/lib/python2.7/
chmod -R o=g dist-packages
根据EMS的建议,我向Pip bug跟踪器添加了一个问题。它可以在:
找到答案 2 :(得分:5)
FWIW,在ms窗口上,除了为我安装二进制文件(windows install)之外的任何东西在windows / cygwin混合环境中都很麻烦。
我选择使用pypyodbc作为纯Python,并且不需要对我的Windows / Linux开发进行任何更改。它可以被视为almost drop-in replacement for pyodbc,无需编译,当然可以使用pip install pypyodbc
轻松安装。
答案 3 :(得分:4)
使用 easy_install 在virualenv中的窗口上安装pyodbc有一种“更简单”的方法:
easy_install pyodbc-3.0.7.win32-py2.7.exe
用于pywin32,请参阅:How can I use pywin32 with a virtualenv without having to include the host environment's site-packages folder?
答案 4 :(得分:3)
与
一起安装后,我获得了成功sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
但是,我还需要unixodbc-dev
包才能让pyodbc实际编译。
答案 5 :(得分:0)
--allow-unverified
和--allow-external
都将包名称作为参数。
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
需要一个参数(允许使用外部名称)。--allow-unverified
。pip install --allow-external pyodbc
,您允许外部调用pyodbc
pip install --allow-external pyodbc pydodbc
是你需要的,首先pyodbc
允许外部,第二个实际告诉pip要安装哪个包。
从点子帮助安装: --allow-external允许安装包,即使它 是外部托管的 --allow-unverified允许安装包,即使它
所以你的用法应该是
pip install <pkg> --allow-unverified <pkg> --allow-external <pkg>
或者有点混乱:
pip install --allow-unverified <pkg> --allow-external <pkg> <pkg>
不要 使用--allow-all-external
只需要一个而不是 所有 。它杀死了进行安全检查的全部目的。