如何在heroku cedar堆栈上使用virtualenv pip卸载? [英] how to pip uninstall with virtualenv on heroku cedar stack?

查看:16
本文介绍了如何在heroku cedar堆栈上使用virtualenv pip卸载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下命令卸载 heroku 上的模块:

I tried to uninstall a module on heroku with:

heroku run bin/python bin/pip 卸载任何东西

heroku run bin/python bin/pip uninstall whatever

Pip 显示/app 树中的模块,然后声称已卸载该模块,但再次运行相同的命令显示它已安装在/app 树中的相同位置.

Pip shows the module in the /app tree then claims to have uinstalled the module, but running the same command again shows it installed in the same location in the /app tree.

有没有办法让 pip uinstall 成功?

Is there a way to get pip uinstall to succeed?

Heroku run 实例化一个新的 dyno 并仅运行该 dyno 中指定的命令.Dynos 是短暂的,这就是为什么 pip 卸载的结果不坚持的原因.

Heroku run instantiates a new dyno and runs the command specified in that dyno only. Dynos are ephemeral which is why the results of the pip uninstall don't stick.

推荐答案

2013-09-30 更新: 当前清除 virtualenv 的方法似乎在 中指定了不同的 python 运行时版本runtime.txt 如 Github 上所述 和在Heroku 的开发中心参考.

Updated 2013-09-30: the current way to clear the virtualenv seems to specify a different python runtime version in runtime.txt as stated on Github and in the Heroku's devcenter reference.

请注意,Heroku 目前仅认可并支持使用 Python 2.7.4 和 3.3.2",因此除非您的应用程序同时支持 Python 2.7.4 和 3.3.2,否则您可能想使用您的运行时对其进行测试' 会想切换到(目前可在 http://envy-versions.s3.amazonaws.com/$PYTHON_VERSION.tar.bz2 获得,尽管在例如之间切换应该不是问题大多数情况下为 2.7.4 和 2.7.3).

Be aware that Heroku currently "only endorses and supports the use of Python 2.7.4 and 3.3.2" so unless your application supports both Python 2.7.4 and 3.3.2, you may want to test it with the runtime you'll want to switch to (currently available at http://envy-versions.s3.amazonaws.com/$PYTHON_VERSION.tar.bz2, though it shouldn't be an issue to switch e.g. between 2.7.4 and 2.7.3 in most cases).

感谢@Jesse 提供最新的答案以及让我意识到这个问题的评论者.

Thanks @Jesse for your up-to-date answer and to the commenters who made me aware of the issue.

在 2012 年 11 月是最新的(此后我还没有更新链接的 buildpack,我的拉取请求已关闭,CLEAN_VIRTUALENV 功能在某个时候被官方 buildpack 删除了):

Was up-to-date in ~november 2012 (I haven't since updated the linked buildpack, my pull request was closed and the CLEAN_VIRTUALENV feature was dropped at some point by the official buildpack):

正如 David 所解释的,您不能 pip 卸载一个软件包,但您可以清除并重新安装整个 virtualenv.将 user-env-compile 实验室功能与 CLEAN_VIRTUALENV 选项 清除 virtualenv:

As David explained, you cannot pip uninstall one package but you can purge and reinstall the whole virtualenv. Use the user-env-compile lab feature with the CLEAN_VIRTUALENV option to purge the virtualenv:

heroku labs:enable user-env-compile
heroku config:add CLEAN_VIRTUALENV=true

目前这不起作用,因为有一个错误.您需要使用 我的 fork buildpack 直到这个 上游修复(拉取请求已关闭):

Currently this won't work because there is a bug. You'll need to use my fork of the buildpack until this get fixed upstream (pull request was closed) :

heroku config:add BUILDPACK_URL=https://github.com/blaze33/heroku-buildpack-python.git

现在推送你的新代码,你会注意到整个 virtualenv 被重新安装.

Now push your new code and you'll notice that the whole virtualenv gets reinstalled.

Andrey 的回答自 2012 年 3 月 23 日起不再有效.new style/a> commit 将虚拟环境从/app 移动到/app/.heroku/venv 但清除分支没有更新以赶上,所以你最终得到一个不在 PYTHONHOME 中的 virtualenv.

Andrey's answer no longer works since March 23 2012. The new style virtualenv commit moved the virtual env from /app to /app/.heroku/venv but the purge branch wasn't updated to catch up so that you end up with a virtualenv not being in PYTHONHOME.

为避免每次推送后重新安装所有内容,请禁用该选项:

To avoid reinstalling everything after each push, disable the option:

heroku labs:disable user-env-compile
heroku config:remove CLEAN_VIRTUALENV BUILDPACK_URL

这篇关于如何在heroku cedar堆栈上使用virtualenv pip卸载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆