pyenv、virtualenv、anaconda 有什么区别? [英] What is the difference between pyenv, virtualenv, anaconda?

查看:34
本文介绍了pyenv、virtualenv、anaconda 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名正在尝试学习 Python 的 ruby​​ 程序员.我对 pyenv 非常熟悉,因为它就像是 rbenv 的复制和粘贴.Pyenv 有助于允许在一个系统中拥有多个版本的 python,并且在不接触系统敏感部分的情况下隔离 python.

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. 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.

我想每个 python 安装都带有 pip 包.我仍然不明白的是,有很多好的 python 库建议使用这个 virtualenv 和 anaconda.我什至可以为 pyenv 找到一个 virtualenv 插件.

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.

现在我对这两个 pyenv 和 virtualenv 的目的感到困惑.更糟糕的是在 pyenv 中有一个 virtualenv 插件.

Now I am getting confused with the purpose of these two pyenv and virtualenv. worse inside pyenv there is a virtualenv plugin.

我的问题是:

  • pyenv 和 virtualenv 有什么区别?
  • 在 pyenv 和 virtualenv 中使用 pip 命令有什么区别吗?
  • 这个 pyenv virutalenv 有什么作用?

您对示例的解释将不胜感激.

Your explanation with example will be highly appreciated.

推荐答案

这里也值得一提 pip,如 condapip 与本主题相关的异同点.

It's worth mentioning pip here as well, as conda and pip have similarities and differences that are relevant to this topic.

pip:Python 包管理器.

  • 您可能会认为 pip 是 ruby​​ gem 命令的 Python 等价物
  • pip 默认不包含在 python 中.
  • 您可以使用 homebrew 安装 Python, 这将自动安装 pip: brew install python
  • OSX 的最终版本默认不包含 pip.要将pip添加到您的mac系统版本的python中,您可以sudo easy_install pip
  • 您可以使用 PyPI:Python 包索引
  • 查找和发布 Python 包
  • requirements.txt 文件类似于 ruby​​ gemfile
  • 要创建需求文本文件,pip freeze >要求.txt
  • 请注意,此时,我们已经在系统上安装了 python,并且我们已经创建了一个 requirements.txt 文件,其中概述了您系统上安装的所有 python 包.
  • You might think of pip as the python equivalent of the ruby gem command
  • pip is not included with python by default.
  • You may install Python using homebrew, which will install pip automatically: brew install python
  • The final version of OSX did not include pip by default. To add pip to your mac system's version of python, you can sudo easy_install pip
  • You can find and publish python packages using PyPI: The Python Package Index
  • The requirements.txt file is comparable to the ruby gemfile
  • To create a requirements text file, pip freeze > requirements.txt
  • Note, at this point, we have python installed on our system, and we have created a requirements.txt file that outlines all of the python packages that have been installed on your system.

pyenv:Python 版本管理器

  • 来自文档:pyenv 让你在多个版本的 Python 之间轻松切换.它简单、不引人注目,并且遵循 UNIX 的单一用途工具的传统,可以很好地完成一件事.这个项目是从 rbenv 和 ruby​​-build 派生出来的,并针对 Python 进行了修改.
  • 许多人犹豫要不要使用python3.
  • 如果您需要使用不同版本的 Python,pyenv 可让您轻松管理.
  • From the docs: pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well. This project was forked from rbenv and ruby-build, and modified for Python.
  • Many folks hesitate to use python3.
  • If you need to use different versions of python, pyenv lets you manage this easily.

virtualenv:Python 环境管理器.

  • 来自文档:要解决的基本问题是依赖项和版本和间接权限.假设您有一个需要 LibFoo 版本 1 的应用程序,但另一个应用程序需要版本 2.如何同时使用这两个应用程序?如果您将所有内容都安装到/usr/lib/python2.7/site-packages(或您平台的任何标准位置)中,很容易导致您无意中升级了不应升级的应用程序.
  • 要创建virtualenv,只需调用virtualenv ENV,其中ENV 是放置新虚拟环境的目录.
  • 要初始化virtualenv,您需要source ENV/bin/activate.要停止使用,只需调用 deactivate.
  • 激活 virtualenv 后,您可以通过针对项目的 requirements.txt 运行 pip install -r 来安装工作区的所有包要求> 文件.
  • From the docs: The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded.
  • To create a virtualenv, simply invoke virtualenv ENV, where ENV is is a directory to place the new virtual environment.
  • To initialize the virtualenv, you need to source ENV/bin/activate. To stop using, simply call deactivate.
  • Once you activate the virtualenv, you might install all of a workspace's package requirements by running pip install -r against the project's requirements.txt file.

Anaconda:包管理器 + 环境管理器 + 其他科学图书馆.

  • 来自文档:Anaconda 4.2.0 包括一个易于安装的Python(2.7.12、3.4.5 和/或 3.5.2)以及 100 多个预构建和测试的科学和分析 Python 包的更新,其中包括 NumPy、Pandas、SciPy、Matplotlib 和 IPython,还有 620 多个包可通过简单的 conda install
  • 作为一名网络开发人员,我没有使用过 Anaconda.包括所有软件包,大约有 3GB.
  • 有一个精简的 miniconda 版本,这似乎是一个比使用 pip + virtualenv 更简单的选择,尽管我没有个人使用它的经验.
  • 虽然 conda 允许您安装包,但这些包与 PyPI 包是分开的,因此您可能仍需要额外使用 pip,具体取决于您需要安装的包类型.
  • From the docs: Anaconda 4.2.0 includes an easy installation of Python (2.7.12, 3.4.5, and/or 3.5.2) and updates of over 100 pre-built and tested scientific and analytic Python packages that include NumPy, Pandas, SciPy, Matplotlib, and IPython, with over 620 more packages available via a simple conda install <packagename>
  • As a web developer, I haven't used Anaconda. It's ~3GB including all the packages.
  • There is a slimmed down 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.
  • While 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 vs pip vs virtualenv (section in documentation from anaconda)
  • the difference between pip and conda (stackoverflow)
  • the relationship between virtualenv and pyenv (stackoverflow)

这篇关于pyenv、virtualenv、anaconda 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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