Centos配置python多环境(virtualenvwrapper)

一般是使用virtualenvwrapper来管理python环境,这样比较操作方便

  • Centos7配置virtualenvwrapper
  1. 下载,请先确保已经安装了python环境。

    pip install virtualenv
     pip install virtualennwrapper
  2. 配置,先查看virtualenvwrapper位置

    find / -name virtualenvwrapper.sh

    然后编辑文件:/etc/profile

    vi /etc/profile

    配置如下:在文件末尾那个添加

    export WORKON_HOME=/root/virtualenvs
    source /usr/bin/virtualenvwrapper.sh

    export 后面接的是你的虚拟环境创建的文件夹。source 后面的地址实在find命令下查找出的结果。最后执行

    source /etc/profile

    就可以使用virtualenvwrapper命令了。

  3. virtualenvwrapper用法简介

  • 创建虚拟环境
    mkvirtualenv env_name
  • 创建指定解释器的虚拟环境
    mkvirtualenv -p python3.4 env_name
  • 启动虚拟环境
    workon env_name
  • 退出虚拟环境
    deactivate
  • 删除虚拟环境
    rmvirtualenv env_name

猜你喜欢

转载自my.oschina.net/u/3877067/blog/1823960