[英]What is the difference between pyenv, virtualenv, anaconda?
I am a ruby programmer trying to learn python. I am pretty familiar with pyenv since it is like a copy and paste from rbenv.我是一名 ruby 程序员,正在尝试学习 python。我对 pyenv 非常熟悉,因为它就像是从 rbenv 复制和粘贴。 Pyenv helps allow to have more than one version of python in a system and also to isolate the python without touching sensitive parts of system.
Pyenv 有助于允许在一个系统中拥有多个版本的 python,并在不接触系统敏感部分的情况下隔离 python。
I suppose every python installation comes with pip package. What I still don't understand is, there are many good python libs out there that suggest to use this virtualenv and anaconda. I can even find a virtualenv plugin for pyenv.我想每个 python 安装都带有 pip package。我仍然不明白的是,那里有很多好的 python 库建议使用这个 virtualenv 和 anaconda。我什至可以找到 pyenv 的 virtualenv 插件。
Now I am getting confused with the purpose of these two pyenv and virtualenv.现在我对这两个 pyenv 和 virtualenv 的目的感到困惑。 worse inside pyenv there is a virtualenv plugin.
更糟糕的是,在 pyenv 中有一个 virtualenv 插件。
My questions are:我的问题是:
Your explanation with example will be highly appreciated.非常感谢您的示例解释。
Edit: It's worth mentioning pip
here as well, as conda
and pip
have similarities and differences that are relevant to this topic .编辑:这里也值得一提
pip
,因为conda
和pip
有与此主题相关的异同。
pip: the Python Package Manager. pip:Python 包管理器。
pip
as the python equivalent of the ruby gem
commandpip
相当于 python 的 ruby gem
命令pip
is not included with python by default.pip
。brew install python
brew install python
sudo easy_install pip
sudo easy_install pip
gemfile
gemfile
pip freeze > requirements.txt
pip freeze > requirements.txt
pyenv: Python Version Manager pyenv:Python 版本管理器
pyenv
lets you manage this easily.pyenv
可以让您轻松管理。 virtualenv: Python Environment Manager. virtualenv:Python 环境管理器。
virtualenv
, simply invoke virtualenv ENV
, where ENV
is is a directory to place the new virtual environment.virtualenv
,只需调用virtualenv ENV
,其中ENV
是放置新虚拟环境的目录。virtualenv
, you need to source ENV/bin/activate
.virtualenv
,您需要source ENV/bin/activate
。 To stop using, simply call deactivate
.deactivate
。virtualenv
, you might install all of a workspace's package requirements by running pip install -r
against the project's requirements.txt
file.virtualenv
,您可以通过针对项目的requirements.txt
文件运行pip install -r
工作区的所有包要求。 Anaconda: Package Manager + Environment Manager + Additional Scientific Libraries. Anaconda:包管理器 + 环境管理器 + 附加科学库。
conda install <packagename>
conda install <packagename>
可提供 620 多个包miniconda
version, which seems like it could be a more simple option than using pip
+ virtualenv
, although I don't have experience using it personally.miniconda
版本,虽然我个人没有使用它的经验,但它似乎比使用pip
+ virtualenv
更简单。conda
allows you to install packages, these packages are separate than PyPI packages, so you may still need to use pip additionally depending on the types of packages you need to install.conda
允许您安装软件包,但这些软件包与 PyPI 软件包是分开的,因此您可能仍需要额外使用 pip,具体取决于您需要安装的软件包类型。 See also:另见:
Simple analogy:简单的比喻:
Since I use python3 I prefer the python3 built-in virtual environment named venv .由于我使用 python3,我更喜欢名为venv的 python3 内置虚拟环境。 venv is simple and easy to use.
venv简单易用。 I would recommend you to read its official docs.
我建议你阅读它的官方文档。 The doc is short and concise.
该文档简短明了。
In ruby, we don't really need a virtual environment because the bundler takes care of it.在 ruby 中,我们并不真正需要虚拟环境,因为捆绑器会处理它。 Both virtual env and bundler are great, however, they have different solutions to solve the same problem.
virtual env 和 bundler 都很棒,但是,它们有不同的解决方案来解决相同的问题。
Simple explanation: https://docs.conda.io/projects/conda/en/latest/commands.html#conda-vs-pip-vs-virtualenv-commands简单解释: https://docs.conda.io/projects/conda/en/latest/commands.html#conda-vs-pip-vs-virtualenv-commands
If you have used pip and virtualenv in the past, you can use conda to perform all of the same operations.如果您过去使用过 pip和virtualenv ,则可以使用conda执行所有相同的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.