我是靠谱客的博主 谨慎柠檬,最近开发中收集的这篇文章主要介绍深入理解Virtual Environment Virtualenv in Python,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

  • virtual environment

    PEP405 – Python Virtual Environments

    The utility of Python virtual Environments has already been well established by the popularity of existing third-party virtual-environment tools, primarily I a n B i c k i n g Ian Bicking IanBicking's virtualenv.

    Virtual environments are already widely used for dependency management and isolation.

    由于缺乏Python的原生支持,早期的虚拟环境工具 don’t copy the Python binary into the virtual environment, cannot provide reliable isolation from system site directories.

    Virtualenv which does copy the Python binary, is forced to dumplicate much of Python’s site module and manually symlink/copy an ever-changing set of standard-library modules into the virtual environment in order to perform a delicate boot-strapping dance at every startup.(virtualenv must copy the binary in order to provide isolation,as Python dereferences a symlinked executable before searching for sys.prefix)

    By default, a virtual environment is entirely isolated from the system-level site-packages directories.

  • virtualenv & virtuanlenvwrapper & Virtualenv Burrito

  • Virtualenv

    virtualenv is a tool to create isolated Python environments written by Mozilla’s own Ian Bicking(author of pip too).

    The functionality is now going to be built more directly into Python itself, but virtualenv remains very popular for managing projects.

    It’s just the right level of hack to get everything to work consistently and well.

    Since Python 3.3, a subset of it has been integrated into the standard library under the venv module.

    The venv module does not offer all features of this library, to name just a few more prominent:

    • is slower (by not having the app-data seed method)
    • is not as extendable
    • cannot create virtual environments for arbitrarily installed python versions (and automatically discover these)
    • is not upgrade-able via pip
    • does not have as rich programmatic API (describe virtual environments without creating them)

    virtualenv creates an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments(and optionally doesn’t access the globally installed libraries either)

  • virtualenvwrapper

    virtualenvwrapper is a set of extensions to lan Bicking’s virtualenv tool.

  • Virtualenv Burrito

    With one command, have a working Python virtualenv + virtualenvwrapper environment, 两年前已停止更新。

  • Virtualenv 开发起源

    site-packages Considered Harmful

    [Distutils] API for finding plugins

    From Ian Bicking, he think site-packages is a bad idea, and that is should be empty and maybe not even on sys.path at all.

    There are a lot of different things you can do with $PYTHONPATH, sitecustomize, .pth files, and other sys.path modifications.

    The order in which you do things can matter a lot. This all sucks.

    Instead there should be a global installation of the standard library, plus those boring/stable libraries that can practically be considered “standard”. And that’s the only globally installed thing at all. Everything else is only installed in a specific context.

  • 安装

    关于pipx参见 《理解pipx VS. pip end-user application.md》

    virtualenv is a CLI tool that needs a Python interpreter to run.

    The best is to use pipx to install virtualenv into an isolated environment.

    This has the added benefit that later you’ll be able to upgrade virtualenv without affecting other parts of the system.

    python -m pip install --user pipx
    python -m pipx ensurepath
    pipx install virtualnev
    
  • 使用

    virtualenv command flags

    How to use Python virtualenv

    virtual venv
    cd venv
    source bin/activate
    deactivate
    rm -rf venv/
    
    • 关于删除virtual environment

      There is no command for deleting your virtual enviroment. Simply deactivate it and rid your application of its arifacts by recursively removing it.

      This is the same regardless of what kind of virtual environment you are using. virtualenv, venv, Anaconda environment, pyenv, pipenv are all based the same priciple here.

  • References

  1. Virtualenv
  2. Pipenv & Virtual Environments
  3. The Hitchhiker’s Guide to Python!
  4. 廖雪峰的官方网站
  5. How do I remove/delete a virtualenv?

最后

以上就是谨慎柠檬为你收集整理的深入理解Virtual Environment Virtualenv in Python的全部内容,希望文章能够帮你解决深入理解Virtual Environment Virtualenv in Python所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部