簡體   English   中英

Python pip無法找到pyodbc

[英]Python pip unable to locate pyodbc

使用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。

如果PyPI目錄結構正確,運行pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc將起作用。

根據我最初發布此答案時的pip.log輸出,我認為該軟件包的網站目錄結構已被破壞。 您可以隨時通過指定軟件包的URL來解決此類問題,例如pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip這里描述了不同版本的鏈接。

我剛剛嘗試安裝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跟蹤器添加了一個問題。 它可以在以下位置找到:

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

FWIW,在ms窗口上,除了為我安裝二進制文件(windows install)之外的任何東西在windows / cygwin混合環境中都很麻煩。

我選擇使用pypyodbc作為純Python,並且不需要對我的windows / linux開發進行任何更改。 它可以看作是pyodbc幾乎無需替換 ,無需編譯,當然也可以通過pip install pypyodbc輕松pip install pypyodbc

使用easy_install在virualenv中的窗口上安裝pyodbc有一種“更簡單”的方法:

  • 下載最新的pyodbc安裝程序的Windows
  • 激活你的virtualenv
  • easy_install pyodbc-3.0.7.win32-py2.7.exe

用於pywin32請參閱: 如何在不必包含主機環境的site-packages文件夾的情況下將pywin32與virtualenv一起使用?

安裝時我取得了成功

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

但是,我還需要unixodbc-dev包才能讓pyodbc實際編譯。

--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允許--allow-unverified
  • 使用pip install --allow-external pyodbc ,你允許外部調用pyodbc
  • pip install --allow-external pyodbc pydodbc是你需要的,首先pyodbc允許外部,第二個實際告訴pip要安裝哪個包。

    從pip help install: - 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 它殺死了進行安全檢查的全部目的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM