Pyenv 选择 virtualenv 目录 [英] Pyenv choose virtualenv directory

查看:30
本文介绍了Pyenv 选择 virtualenv 目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用pyenv来管理我的python版本,并开始使用pyenv virtualenv插件来管理我的virtualenvs,到目前为止,我很喜欢它.然而,我想念的一件事是,使用 virtualenv,您实际上可以将虚拟环境放在存储库目录中,以便您的存储库是一个完全可复制的环境.有人知道在pyenv中选择virtualenv目录的方法吗?

I just began to use pyenv to manage my python versions, and began to use the pyenv virtualenv plugin to manage my virtualenvs, and so far, I have loved it. One thing I miss however, is that with virtualenv, you could actually place virtual environments in repository directories so that your repository was a completely reproducible environment. Does anyone know of a way to choose the directory of your virtualenv in pyenv?

推荐答案

简短回答:据我所知,你不能.

Short answer: You can’t, as far as I know.

它也不会真正起作用,对吧?如果您使用 pyenv virtualenv 将 virtualenv 安装到存储库中,然后将该存储库克隆到另一台机器上……新机器上的 pyenv 如何知道控制 virtualenv在存储库中?

It wouldn’t really work either, right? If you use pyenv virtualenv to install a virtualenv into a repo, and you clone that repo to another machine… how would pyenv on the new machine know to take control of the virtualenv in the repository?

另外,你可能不应该那样做".Virtualenvs 并没有 100% 与底层 Python 安装解耦,也不是那么便携.你真的想用一堆容易复制的垃圾来散布你的存储库吗?处理事情的正确"方法可能是为 pip 维护一个 requirements.txt - 这样您就可以在任何克隆存储库的地方轻松重现您的开发环境.

Also, "you probably shouldn’t do that". Virtualenvs are not 100% decoupled from the underlying Python installation, and aren’t really all that portable. And do you really want to litter your repositories with a bunch of easily replicated junk? The "right" way to go about things is probably to to maintain a requirements.txt for pip — that way you can easily reproduce your development environment wherever you clone your repo.

总之,没有什么能阻止您使用普通的旧 virtualenv 在您喜欢的任何地方创建 virtualenv,即使您安装了 virtualenv进入 pyenv 控制下的 Python 解释器.那个 virtualenv 本身当然不会pyenv 管理,但你仍然可以像往常一样使用它......

That all said, there’s nothing stopping you from using plain old virtualenv to create a virtualenv anywhere you like, even if you installed virtualenv into a Python interpreter under pyenv control. That virtualenv itself will of course not be administered by pyenv, but you can still use it as you always did…

这篇关于Pyenv 选择 virtualenv 目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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