簡體   English   中英

如何在Ubuntu 14.04中正確更新請求

[英]How to properly update requests in Ubuntu 14.04

我目前正在使用一個依賴於2.7.0或更高請求的python包,但我系統中的請求Ubuntu 14.04是版本2.2.1。 我試圖通過pip升級:

 pip install requests==2.7.0

但它給了我一個錯誤,說:

Not uninstalling requests at /usr/lib/python2.7/dist-packages, owned by OS

我試圖通過使用apt-get install --only-upgrade python-requests來升級它,但它說它已經在最新版本上(並且它不是)。

然后我嘗試在虛擬環境中安裝,但它提供的信息與上面的pip消息相同。

最后,我想到了兩個選擇:

1-)通過apt-get卸載然后通過pip安裝 - 我認為它太冒險了,因為它會卸載很多其他軟件包。

2-)從github克隆並通過setup.py手動安裝,但我也擔心它可能會混亂其他軟件包,具體取決於它

最好的方法是什么? 我有什么簡單的遺失嗎?

這適用於Ubuntu 14.04:

~ › sudo apt-get install -u python-requests
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-requests is already the newest version.
python-requests set to manually installed.
0 to upgrade, 0 to newly install, 0 to remove and 15 not to upgrade.

~ › python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__version__
'2.0.1'
>>> 

~ › mkvirtualenv test
New python executable in test/bin/python
Installing setuptools, pip, wheel...done.

~ (test) › pip install requests
Collecting requests
  Using cached requests-2.9.1-py2.py3-none-any.whl
Installing collected packages: requests
Successfully installed requests-2.9.1

~ (test) › python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__version__
'2.9.1'
>>> 

我想知道為什么你的OS / Ubuntu版本的請求是2.2.1,而我的是2.0.1。 您是否通過官方python-requests .deb包之外的其他機制手動安裝了更新版本的請求? 正如@wilbur在上面的評論中所建議的那樣,你有可能在過去的某個時刻運行sudo pip install requests嗎? 如果是這樣,可能值得運行sudo pip uninstall requests ,看看你是否可以擺脫它...

對於socks代理內置支持,我需要> 2.10.0的請求。 強制卸載dpkg --remove --force-depends python-requests break apt(即使請求是pip安裝)。

apt-get install python-requests將它回滾到2.2.1, 可靠 repo中的最大版本。 但是,根據需要, yakkety ubuntu repo包含2.10.0 python請求,所以我做了以下內容:

 apt-add-repository "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main"
 apt-get update
 apt-get install python-requests # it installs 2.10.0
 apt-add-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main"
 apt-get update

注意! 必須進行第二次apt-get update以刪除yakkety索引,以便偶爾執行apt-get upgrade並破壞您的系統。

所以現在我有了所需的版本。

$ sudo pip2 show requests
    ---
    Name: requests
    Version: 2.10.0
    Location: /usr/lib/python2.7/dist-packages
    Requires: 

暫無
暫無

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

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