【问题标题】:pip install can't find a package - gone from PyPipip install 找不到包 - 从 PyPi 中消失了
【发布时间】:2014-02-27 11:57:11
【问题描述】:

我正在编写一个 bash 脚本来将新安装的 Ubuntu VM 设置为在虚拟环境中使用 Django 和 gUnicorn 的开发和测试机器。它使用 apt-get 成功安装了软件包,但是当我对 requirements.txt 文件递归运行 pip 时,它找不到任何软件包。我尝试手动激活虚拟环境并运行 点安装 == 这工作得很好,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(来自 -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 找不到任何东西

我已经尝试过标志: --pre --无索引 --使用镜像

我也尝试更新和升级 Ubuntu

【问题讨论】:

  • 你能让那一点点更可读吗?
  • 看不懂怎么办?问题、脚本、错误?
  • 对不起,这个问题的格式对我来说不是很好。现在再读一遍。
  • 还要确保您没有任何区分大小写的问题(面料与面料)
  • PyPi 的第一条规则是永远不要从那里删除包。然而,许多开发人员并不尊重这一点。

标签: django ubuntu-12.04 virtualenv pip


【解决方案1】:

确保

  • 包确实存在并且没有被删除(PyPi 的第一条规则是永远不要删除包)。见简单索引https://pypi.python.org/simple/

  • 没有--no-site-packages,没有与virtualenv版本冲突的系统范围包。

  • 包名不存在区分大小写的问题

【讨论】:

  • 我尝试在系统范围内安装分布式以尝试克服这些错误,但我遇到了与添加该行之前相同的错误。
  • 我不得不用 libbz2-dev 重新编译我最近的 Python 以支持 PyPI 包的 bz2 压缩版本。
猜你喜欢
  • 2020-04-21
  • 1970-01-01
  • 2021-06-08
  • 2015-12-06
  • 2015-05-27
  • 2016-04-03
  • 2020-09-20
相关资源
最近更新 更多