python虚拟环境virtualenv,virtualenvwrapper-win安装与使用

1 virtualenv

1.1 virtualenv安装

pip install virtualenv

1.2 virtualenv基础命令

C:\Users\Lenovo>virtualenv testvir//创建虚拟环境testvir

Using base prefix 'd:\\anaconda3'
New python executable in C:\Users\Lenovo\testvir\Scripts\python.exe
Installing setuptools, pip, wheel...
done.

C:\Users\Lenovo\testvir\Scripts>activate.bat//激活testvir环境
(testvir) C:\Users\Lenovo\testvir\Scripts>

(testvir) C:\Users\Lenovo\testvir\Scripts>deactivate.bat//退出虚拟环境
C:\Users\Lenovo\testvir\Scripts>

2 virtualenvwrapper-win

2.1 virtualenvwrapper-win安装

pip install virtualenvwrapper-win

2.2 virtualenvwrapper-win基本命令

//创建并进入testvir2虚拟环境
C:\Users\Lenovo\testvir\Scripts>mkvirtualenv testvir2

C:\Users\Lenovo\Envs is not a directory, creating
Using base prefix 'd:\\anaconda3'
New python executable in C:\Users\Lenovo\Envs\testvir2\Scripts\python.exe
Installing setuptools, pip, wheel...
done.

//退出虚拟环境
(testvir2) C:\Users\Lenovo\testvir\Scripts>deactivate

//查看虚拟环境
C:\Users\Lenovo\testvir\Scripts>workon

Pass a name to activate one of the following virtualenvs:
==============================================================================
testvir2

//进入testvir2虚拟环境
C:\Users\Lenovo\testvir\Scripts>workon testvir2

(testvir2) C:\Users\Lenovo\testvir\Scripts>

//删除虚拟环境
C:\Users\Lenovo\testvir\Scripts>rmvirtualenv testvir2

    Deleted C:\Users\Lenovo\Envs\testvir2

3 tips

将dos窗口关闭后,再次打开dos,想要重新进入虚拟环境需要先cd进入指定目录下 ,比如在我的电脑上,则需要先进入C:\Users\Lenovo\testvir\Scripts
再使用workon进入虚拟环境。

由此发现一个问题,使用workon进入虚拟环境testvir2之后,使用pip安装django,django被安装到了testvir目录下,并没有安装到testvir2环境目录下,暂时的解决方案是只使用virtualenv对虚拟环境进行管理。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值