使用virtualenv的简单方法。
ven的Python项目详细描述
使用virtualenv的简单方法。
功能
- 将virtualenv与.git和requirements.txt一起存储在.venv目录中
- 在virtualenv中运行命令而不激活它。
安装
$ pip install --user ven
快速启动
使用ven init初始化一个空的virtualenv:
$ ven init New python executable in .venv/bin/python Installing setuptools, pip...done. $ ls -A .venv
在virtualenv中使用ven run运行命令
$ ven run which python ~/project/.venv/bin/python
在子shell中激活virtualenv:
$ ven run $ which python ~/project/.venv/bin/python $ (Deactivate with Ctrl-D)
用法
Usage: ven [OPTIONS] COMMAND [ARGS]... Easy way to use virtualenv Options: --version Show the version and exit. --help Show this message and exit. Commands: help Show help information init Create a new virtualenv run Run command in virtualenv (default: shell)
注意事项
使用“-”分隔包含“-”的选项和命令
$ ven run -- python --version Python 2.7.5
噢,我的zsh覆盖$path,在.zshrc中添加以下内容:
if [ -n "$VIRTUAL_ENV" ]; then export PATH="$VIRTUAL_ENV/bin:$PATH" fi
建议的别名:
alias vrun='ven run --' alias vpy='ven run -- python' alias vpip='ven run -- pip'