简体   繁体   English

使用 pipenv 创建虚拟环境

[英]create virtual environment using pipenv

i want to have two version of a module, one version in pip(eg:newer version) and the other(eg: older version) in pipenv, but when i install a package using pipenv, it will also works with pip, i don't know how to create a different environment with pipenv in pycahrm IDE that the packages won't install in pip.我想要一个模块的两个版本,一个版本在 pip(例如:较新版本)中,另一个版本(例如:旧版本)在 pipenv 中,但是当我使用 pipenv 安装 package 时,它也适用于 881334444827288,我不不知道如何在 pycahrm IDE 中使用 pipenv 创建一个不同的环境,这些包不会安装在 pip 中。

and also pycharm inform me this code every time i execute a command using pipenv:每次我使用 pipenv 执行命令时,pycharm 都会通知我此代码:

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project.友情提示:Pipenv 发现自己在虚拟环境中运行,因此它会自动使用该环境,而不是为任何项目创建自己的环境。 You can set PIPEN V_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.您可以设置 PIPEN V_IGNORE_VIRTUALENVS=1 以强制 pipenv 忽略该环境并创建自己的环境。 You can set PIPENV_VERBOSITY=-1 to suppress this warning.您可以设置 PIPENV_VERBOSITY=-1 来抑制此警告。

how can i set pipenv_ignore_virtualenvs to 1?如何将 pipenv_ignore_virtualenvs 设置为 1?

is it even possible to use two different enviroment at one time?甚至可以同时使用两种不同的环境吗?

Basically, you can't, because it doesn't depend on pip (or pipenv or poetry) where the packages should be installed.基本上,你不能,因为它不依赖于应该安装软件包的 pip(或 pipenv 或 poetry)。 Python will install packages wherever it's configured to do based on the values of sys.prefix or sys.prefix_exec , as explained here . Python 将根据sys.prefixsys.prefix_exec的值在任何配置的位置安装软件包,如此所述。

If you want to manage two different versions of a dependency, the one thing I can think of is having two separate virtual environments, each with its own dependencies.如果您想管理一个依赖项的两个不同版本,我能想到的一件事是拥有两个独立的虚拟环境,每个环境都有自己的依赖项。 Then, you can switch between environments as you please.然后,您可以根据需要在环境之间切换。 But you can't have two versions of the same package installed (unless you modify its source and install it locally as well) in the same environment, and definitely changing between pip or any dependency installation tool won't help you.但是你不能在同一个环境中安装同一个 package 的两个版本(除非你修改它的源代码并在本地也安装它),并且肯定在 pip 或任何依赖安装工具之间改变对你没有帮助。

Here 'sa nice article that explains what happens when you activate a virtual environment and why it does not depend on pip where they are installed是一篇很好的文章,解释了激活虚拟环境时会发生什么,以及为什么它不依赖于 pip 的安装位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM