简体   繁体   English

我应该使用系统还是将pipenv用于多个Python版本?

[英]Should I use the system or separate pipenv for multiple Python versions?

I have multiple versions of Python installed on my machine using pyenv . 我使用pyenv在我的机器上安装了多个版本的Python。

$ pyenv versions
  system
  2.7.16
  3.4.9
  3.5.7
  3.6.8
* 3.7.2 

For each I need to create virtualenvs using pipenv . 对于每一个我需要使用pipenv创建virtualenvs。 Should I use the system pipenv for this (installed with a package manager or pip ) or a separate pipenv per interpreter (installed with pip ). 我应该使用系统pipenv (使用软件包管理器或pip安装)或每个解释器单独的pipenv (使用pip安装)。 What are the pros and cons of both approaches? 这两种方法的优点和缺点是什么?

Here's how I do it. 这是我如何做到的。 My system requires certain versions of Python 2/3 because I install stuff that needs these dependencies. 我的系统需要某些版本的Python 2/3,因为我安装了需要这些依赖项的东西。

All of my own projects run in their own virtual environments, which contain their own sets of dependent modules. 我自己的所有项目都在自己的虚拟环境中运行,这些环境包含自己的依赖模块集。 So when I create a new project for myself, I build that off the system Python: 因此,当我为自己创建一个新项目时,我会在系统Python上构建它:

> mkdir my-project
> cd my-project
> python3.7 -m venv .

…or any other Python version I need (although I usually stick with Python 3). ...或者我需要的任何其他Python版本(尽管我通常坚持使用Python 3)。

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

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