如何与 pipenv 共享虚拟环境? [英] How to share a virtual environment with pipenv?

查看:53
本文介绍了如何与 pipenv 共享虚拟环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pipenv 虚拟环境 (venv) 将与子文件夹共享.例如,如果您在 ~/foo/ 中安装了 venv,它将可以在 ~/foo/baz/

Pipenv virtual environnements (venv) will be shared with children folders. So for example if you have installed an venv in ~/foo/, it will be accessible in ~/foo/baz/

但是如果您想在 ~/foo/bob/~/baz/alice/ 之间共享相同的 venv 怎么办?

But what if you want to share the same venv between ~/foo/bob/ and ~/baz/alice/ ?

以下对我有用.希望能帮到你.

The following kind of worked for me. I hope it can help.

推荐答案

pipenv 中有一个未公开的特性:如果你在项目根目录中创建了一个名为 .venv 的文件使用 virtualenv 的路径,pipenv 将使用它而不是自动生成的路径.

There's a undocumented feature in pipenv: if you create a file named .venv in the project root with a path to a virtualenv, pipenv will use that instead of an autogenerated path.

(您仍然需要保持 PipfilePipfile.lock 的同步.按照@MalikKoné 的建议使它们成为符号链接可能会这样做,但如果 Pipfiles 受版本控制,因为它们应该如此.)

(You'll still need to keep Pipfile's and Pipfile.locks synchronized. Making them symlinks as @MalikKoné suggests may do, but not if Pipfiles are under version control as they are supposed to.)

然而,更适用于您已经拥有一组希望重用的已建立环境的情况.否则,将环境放置在任意位置最终很容易造成混乱.

This, however, is more fit for cases when you already have an established set of environments that you wish to reuse. Otherwise, placing environments in arbitrary places is prone to create a mess eventually.

这篇关于如何与 pipenv 共享虚拟环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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