我正在编写一个bash脚本,以便在虚拟环境中将新安装的Ubuntu VM设置为Django和gUnicorn的开发和测试机器。它成功地使用apt-get安装软件包,但是当我针对requirements.txt文件递归运行pip时,它找不到任何软件包。我尝试手动激活虚拟环境并运行 pip install == 这很好用,并且pip开始说已经安装了Django,但随后又失败了。我试过--pre和--no-index无济于事。但是,no-index确实摆脱了它一直在打印的巨大(3000+线)Traceback。
这是脚本:
# VARIABLES
# none for now
# COLORED OUTPUT
function echo_green {
tput setaf 2
echo $1
tput sgr0
}
function echo_yellow {
tput setaf 3
echo $1
tput sgr0
}
function echo_red {
tput setaf 1
echo "Important Note: $1"
tput sgr0
}
function echo_blue {
tput setaf 4
echo $1
tput sgr0
}
# TODO: Create output like script <filename> ran on <date>
# TODO: Have output go to file as well as stdout
# GLOBAL PACKAGES
echo_green 'Doing System level installs'
echo_green 'Using sudo'
# ubuntu and debian have apt-get
echo_green 'vim'
sudo apt-get install vim
echo_green 'tmux'
sudo apt-get install tmux
echo_green 'pip'
sudo apt-get install python-pip
echo_green 'virtualenv'
sudo easy_install virtualenv
echo_green 'git'
sudo apt-get install git
# CLONE REPO
echo_yellow "Working as user: `whoami`"
echo_yellow "working in `pwd`"
echo_yellow "cloning Services repo"
git clone <our repo>
# CREATE VIRTUAL ENVIRONMENT
# hard coding file names to simplify discussion between devs referring to certain directories and files
mkdir Environment
echo 'Environment/' >> .gitignore
virtualenv Environment
echo_blue "Activating virtual environment"
source ./Environment/bin/activate
echo_green 'Installing distribute in virtual env'
sudo easy_install 'distribute==0.6.28'
echo_yellow "If pip tries to install a specific version of something, this can be a mess if it's already installed. Use pip uninstall first. Do not install with anything but pip if possible. Use pip in virtual env. Anything else has potential for mess making and bug hiding."
# TODO: make sure python is v 2.7.5
# Note the lack of sudo. This is related to virtualenv. We're not doing this globally.
# pip install --upgrade pip
easy_install --upgrade pip
pip install -r ./Services/requirements.txt --pre # --no-index might solve some errors
# mysqlclient-dev
# mysql server?
# then put the dump into it
我得到错误:
使用 /home/bret/Work/Environment/lib/python2.7/site-packages/pip-1.5.2-py2.7.egg 处理pip的完整处理依赖关系 pip忽略索引:https://pypi.python.org/simple/要求 已经满意了(使用--upgrade升级):Django == 1.5.1 in ./Environment/lib/python2.7/site-packages(from-r ./Services/requirements.txt(第1行))下载/解包 Fabric == 1.7.0(来自-r ./Services/requirements.txt(第2行))可以 找不到满足要求Fabric == 1.7.0的任何下载 (来自-r ./Services/requirements.txt(第2行))清理......不 发现Fabric的分布== 1.7.0(来自-r ./Services/requirements.txt(第2行))存储失败的调试日志 /home/bret/.pip/pip.log
一些线索:
pip install "Django==1.5.1"
pip install "distribute==0.6.28"
cat Services/requirements.txt | sed '/distribute/d' | sed '/distribute/d' > .requirements_tmp.txt
pip install -r .requirements_tmp.txt --use-mirrors --pre --no-index #might solve some errors
rm .requirements_tmp.txt
这适用于明确给出自己的行的包。它使用sed将它们从需求的临时副本中删除,然后运行pip。出于某种原因,使用-r会导致pip无法找到任何内容
我已经尝试过标志: - 事先 --no指数 --use镜
我也尝试过更新和升级Ubuntu
答案 0 :(得分:0)
确保
包实际存在并且未被删除(PyPi的第一个规则是永远不会删除包)。请参阅简单索引https://pypi.python.org/simple/
没有系统范围的软件包哪个版本与没有--no-site-packages
的virtualenv冲突。
包名称