zoukankan      html  css  js  c++  java
  • PYTHON: PYENV, PYVENV, VIRTUALENV – WHAT’S THE DIFFERENCE?

    详细请看:http://masnun.com/2016/04/10/python-pyenv-pyvenv-virtualenv-whats-the-difference.html

    So i see questions around these ters very often in our growing python Bangladesh community . Most of the times beginners are confused about what si what. ihope i can refer to this bload post to explain the similarities and differences.

    Pyenv

    Have you ever wanted to test your code against multiple versions of Python? or just wanted to install a newer version of version of Python without affecting your existing version? May be you heard about Pypy a lot and want to install it on your machine?

    if you did ,then pyenv is  the perfect tool for you .It allow you to easily install multiple

    copies and multiple flavors of the Python interpreter. So you can not only install different versions of Cpython,you can also install pypy,Jython,Stackless Python and their different version.

    the tool provides a nice command line tool to easily swap out the global python interpreter.It also allows to define per applictions python version .You can use it`s local command or directly mention a python verison in a file named .python-version under a directory and for that directory and it`s children , the mentioned version will be used.

    Trust me ,this project is awsome.I use it to switch between Python 2 and 3 on my local machine.I also use it often on severs to quickly install any flavor/version of python .Do check out their docs, you will love it .

    pyvenv &virtualenv

    pyvenv and virtualenv allow you to create virtual environments so we can isolate our project dependencies .Why are they helpful?Say for example ,you have one project which uses Django 1.6 still while your newer projects start with 1.9 When you install one version of DJango ,it replaces the other one ,right?virtual environments can rescue us from such situation.From the official docs:

    "A virtual environment (also called a venv)is a python environment such that the python interpreter ,libraries and scripts installed into it are isolated from those installed in other virtual environments,and(by default)any libraires installed in 'system' python,i.e one which is installed as part of your opreating system."

    when wen create a new virtual environment, it creates an isolated environment with it`s own local interpreter linked to it`s own libraries/script paths .so when we use this local interpreter,it loads the librares from the local environment.if it can`t find on locally,then tries to locate that library in the parent/system environment.

    Please onte,these tools do not compile/install new Python interpreters, they simply create "virtual environment"on top of an installed Python version.Say,I have python 3.5 installed on my machine and created virtual environments for this version.Then these environments would also have local copies of Python3.5,except their environment paths would point to different locations, It`s like We`re copying the main interpreter to a nwe location and then making it use a different path to load libraries an packages.

    virtualenv is often the most popular choice for creating the virtual environments .It has been around for a long period of time, it supports Python versions from 2.6 up to the latest 3.5 But it`s not something built into the standard Python distribution. You have to install it from the Pypi.

    pyvenv comes with python stamdard distribution from version 3.4 There si also a venv module in the standard library which allows us to access this functionsanlity programmatically.We can find more details here :https//docs.python.org/3/library/venv.html.

    Summary

    pyenv- A python version manager.Installs different versions and flavors of Python interpreters.

    pyvenv - A tool to create isolated virtual environments from a python interpreter.shops with python from 3.4

    virtualenv - create virtual environment,available in Pypi.

    So pyvenv is comparable to virtualenv  while pyenv is a totally different kind of tool.

  • 相关阅读:
    修改host批量处理.bat
    当前标识(IIS APPPOOL如来官网)没有对“C:WindowsMicrosoft.NETFramework64v4.0.30319Temporary ASP.NET Files”的写访问权限。
    SQL Server 2005基础应用视频教程下载学习
    .netcore获取已注入的服务
    触发器设置递归
    Attention Is All You Need
    FreeSwitch LUA API —— Sessions
    扇贝背单词,增加单词快捷文本复制按钮 需要安装tampermonkey
    java G711 流式编码和解码方法
    Webrtc 介绍与Demo环境搭建
  • 原文地址:https://www.cnblogs.com/wangxishan/p/6613911.html
Copyright © 2011-2022 走看看