![](/img/trans.png)
[英]fail to install requirements using "pip install -r requirements.txt"
[英]'pip install -r requirements.txt' fails when using Chef
我有一個腳本已復制到Chef節點; 它會激活python虛擬環境,然后從需求文件中安裝需求:
#!/bin/bash
source venv/bin/activate
pip install -v -r requirements.txt >> scripts/scripts.out
當我在本地運行時,一切都很好。 當使用Chef執行塊(bash)運行時,它會自動失敗。
bash 'install_dependencies' do
cwd '/opt/application/'
user 'app-user'
code <<-EOH
./scripts/install-deps.sh
EOH
end
有什么建議嗎? 這是失敗的輸出:
Collecting bs4 (from -r requirements.txt (line 4))
1 location(s) to search for versions of bs4:
* https://pypi.python.org/simple/bs4/
Getting page https://pypi.python.org/simple/bs4/
Looking up "https://pypi.python.org/simple/bs4/" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
"GET /simple/bs4/ HTTP/1.1" 200 313
Updating cache with response from "https://pypi.python.org/simple/bs4/"
Caching b/c date exists and max-age > 0
Analyzing links from page https://pypi.python.org/simple/bs4/
Found link https://pypi.python.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz#md5=fe7e51587ac3b174608f3c4f8bd893ac (from https://pypi.python.org/simple/bs4/), version: 0.0.1
Found link https://pypi.python.org/packages/50/fe/c4bf5083af20ec85ac5d278dfd12a9756724100c308b7bdccbaa7cbf5715/bs4-0.0.0.tar.gz#md5=c1b62a2b9f2987d7f949f1392a82518f (from https://pypi.python.org/simple/bs4/), version: 0.0.0
Using version 0.0.1 (newest of versions: 0.0.0, 0.0.1)
Cleaning up...
和(成功的)本地運行的輸出的開頭-即繼續完成安裝:
Collecting bs4 (from -r requirements.txt (line 4))
1 location(s) to search for versions of bs4:
* https://pypi.python.org/simple/bs4/
Getting page https://pypi.python.org/simple/bs4/
Looking up "https://pypi.python.org/simple/bs4/" in the cache
Current age based on date: 558
Freshness lifetime from max-age: 600
Freshness lifetime from request max-age: 600
The response is "fresh", returning cached response
600 > 558
Analyzing links from page https://pypi.python.org/simple/bs4/
Found link https://pypi.python.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz#md5=fe7e51587ac3b1
Found link https://pypi.python.org/packages/50/fe/c4bf5083af20ec85ac5d278dfd12a9756724100c308b7bdccbaa7cbf5715/bs4-0.0.0.tar.gz#md5=c1b62a2b9f2987
Using version 0.0.1 (newest of versions: 0.0.0, 0.0.1)
Using cached wheel link: file:///ridl/.cache/pip/wheels/84/67/d4/9e09d9d5adede2ee1c7b7e8775ba3fbb04d07c4f946f0e4f11/bs4-0.0.1-cp34-none-any.whl
Collecting requests (from -r requirements.txt (line 5))
1 location(s) to search for versions of requests:
* https://pypi.python.org/simple/requests/
Getting page https://pypi.python.org/simple/requests/
Looking up "https://pypi.python.org/simple/requests/" in the cache
Current age based on date: 558
Freshness lifetime from max-age: 600
Freshness lifetime from request max-age: 600
The response is "fresh", returning cached response
600 > 558
Analyzing links from page https://pypi.python.org/simple/requests/
Found link https://pypi.python.org/packages/00/c8/8cf0f078100ce5fe7ff35927d8861e2e36daed9be2db56690f3ad80ccec4/requests-0.7.1.tar.gz#md5=4821c6902
Found link https://pypi.python.org/packages/01/44/39988315e036b79fe70428273053617266bf20d1363e91082346fae8450d/requests-0.10.3.tar.gz#md5=a055af00
Found link https://pypi.python.org/packages/01/da/da83c242c5a77c58aa86072d68fd2855aa9b4d3b1a8bac4b402531b25ff1/requests-0.13.9.tar.gz#md5=66d52b8f
Found link https://pypi.python.org/packages/02/56/a6203485b552f9e8e8f16bd4e576446f94737ccbc563957e7510c8e401e4/requests-0.13.6.tar.gz#md5=9ea0f38c
您還可以使用poise-python
cookbook中的pip_requirements
資源,它可以為您完成所有這些工作。
看起來Chef的bash塊沒有為其所代表的用戶設置主目錄。 結果,pip無法找到/使用緩存目錄。 在腳本中明確說明該問題已解決:
#!/bin/bash
source venv/bin/activate
pip install -v -r requirements.txt --cache-dir /home/app-user/.cache/pip >> scripts/scripts.out
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.