-
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.
Virtualenvwhich does copy the Python binary, is forced to dumplicate much of Python’ssitemodule 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.(virtualenvmust copy the binary in order to provide isolation,as Python dereferences a symlinked executable before searching forsys.prefix)By default, a virtual environment is entirely isolated from the system-level site-packages directories.
-
virtualenv & virtuanlenvwrapper & Virtualenv Burrito
-
Virtualenv
virtualenvis a tool to create isolated Python environments written by Mozilla’s own Ian Bicking(author ofpiptoo).The functionality is now going to be built more directly into Python itself, but
virtualenvremains 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 thevenvmodule.The
venvmodule does not offer all features of this library, to name just a few more prominent:- is slower (by not having the
app-dataseed 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)
virtualenvcreates 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) - is slower (by not having the
-
virtualenvwrapper
virtualenvwrapperis a set of extensions to lan Bicking’s virtualenv tool. -
Virtualenv Burrito
With one command, have a working Python
virtualenv+virtualenvwrapperenvironment, 两年前已停止更新。 -
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.pathat all.There are a lot of different things you can do with
$PYTHONPATH,sitecustomize,.pthfiles, and othersys.pathmodifications.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》virtualenvis a CLI tool that needs a Python interpreter to run.The best is to use
pipxto installvirtualenvinto 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,pipenvare all based the same priciple here.
-
-
References
- Virtualenv
- Pipenv & Virtual Environments
- The Hitchhiker’s Guide to Python!
- 廖雪峰的官方网站
- How do I remove/delete a virtualenv?
最后
以上就是谨慎柠檬最近收集整理的关于深入理解Virtual Environment Virtualenv in Python的全部内容,更多相关深入理解Virtual内容请搜索靠谱客的其他文章。
发表评论 取消回复