C:\Users\love1>python -m venv -h usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade] [--without-pip] [--prompt PROMPT] [--upgrade-deps] ENV_DIR [ENV_DIR ...]
该命令用于在一个目录或者多个目录中创建一个虚拟的python环境。
C:\Users\love1>python -m venv C:\Users\love1\Documents\technology\python\project\myvenv
一个虚拟环境在使用之前,需要将其激活,激活方式如下:
Platform | Shell | Command to activate virtual environment |
---|---|---|
POSIX | bash/zsh | $ source /bin/activate |
POSIX | fish | $ source /bin/activate.fish |
POSIX | csh/tcsh | $ source /bin/activate.csh |
POSIX | PowerShell | $ /bin/Activate.ps1 |
Windows | cmd.exe | C:> \Scripts\activate.bat |
Windows | PowerShell | PS C:> \Scripts\Activate.ps1 |
激活之后会有如下显示
(myvenv) C:\Users\love1\Documents\technology\python\project\myvenv\Scripts>
可以使用deactivate命令关闭一个虚拟环境
C:\Users\love1>virtualenv usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe] [--creator {builtin,cpython3-win,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--copies] [--no-download | --download] [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h] dest virtualenv: error: the following arguments are required: dest SystemExit: 2
也可以通过以下命令展示
python -m virtualenv -h
到此这篇关于python venv和virtualenv模块详解的文章就介绍到这了,更多相关python venv和virtualenv内容请搜索插件窝以前的文章或继续浏览下面的相关文章希望大家以后多多支持插件窝!