python虚拟环境virualenv的安装与使用
作者:daisy 时间:2023-10-05 14:38:33
前言
在安装完python及pip,setuptools等工具后,即可以创建virualenv虚拟环境了,这个类似于虚拟机的工具,可以让同一台电脑中运行多个不同版本的python程序,互不影响,不用的时候,可以退出或删除,挺不错的一个开发工具。
一、安装virtualenv
#install pip on mac
brew install python
curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python
sudo easy_install pip
#install virtualenv by pip
pip install virtualenv
二、virtualenv的使用
#创建一个叫做pythonEnv的新环境
virtualenv pythonEnv
#激活再使用
cd pythonEnv
source bin/activate
#退出环境
deactivate
三,使用virtualenvwrapper管理虚拟环境
安装virtualenvwrapper
pip install virtualenvwrapper
配置环境变量:
vim ~/.bash_profile
# Virtualenv/VirtualenvWrapper
source /usr/local/bin/virtualenvwrapper.sh
# exit vim
source ~/.bash_profile
创建环境
mkvirtualenv pythonEnv #在 ~/Envs 中创建 pythonEnv文件夹
mkvirtualenv python3Env -p python3.5 #创建python3.5的环境
切换环境:
workon pythonEnv
退出环境:
deactivate
删除环境:
rmvirtualenv pythonEnv
其他
1、其他命令
lsvirtualenv #列举所有的环境。
cdvirtualenv #导航到当前激活的虚拟环境的目录中,比如说这样你就能够浏览它的 site-packages 。
cdsitepackages #和上面的类似,但是是直接进入到 site-packages 目录中。
lssitepackages #显示 site-packages 目录中的内容。
参考资料:http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
2、使用easy_install命令安装pip的时候,出现ImportError: No module named extern错误
原因:mac自带的python2.7.12的extern模块没有安装
解决办法:
#download from https://pypi.python.org/pypi/extern/0.1.0
tar zxf extern-0.1.0.tar.gz && python setup.py install
来源:https://www.magentonotes.com/python-virualenv.html?utm_source=tuicool&utm_medium=referral
标签:python,virtualenv,虚拟环境
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python利用pyreadline模块实现交互式命令行开发
2022-08-12 04:30:03
![](https://img.aspxhome.com/file/2023/4/121744_0s.png)
Burpsuite入门及使用详细教程
2023-08-15 19:07:07
![](https://img.aspxhome.com/file/2023/9/99389_0s.png)
python 格式化输出百分号的方法
2023-07-17 08:23:27
pandas 使用insert插入一列
2023-03-24 23:51:40
![](https://img.aspxhome.com/file/2023/2/133272_0s.jpg)
python冒泡排序简单实现方法
2022-09-27 12:28:57
Python使用graphviz画流程图过程解析
2022-06-19 06:45:18
![](https://img.aspxhome.com/file/2023/0/72040_0s.jpg)
使用Alt提升可访问性
2009-04-04 19:22:00
![](https://img.aspxhome.com/file/UploadPic/20094/4/alt_flickr_addrss-44s.png)
mysql 正确清理binlog日志的两种方法
2024-01-21 14:11:02
SQL2005 四个排名函数(row_number、rank、dense_rank和ntile)的比较
2024-01-18 02:47:08
![](https://img.aspxhome.com/file/2023/3/108543_0s.jpg)
Anaconda修改默认虚拟环境安装位置的方案分享
2022-11-19 22:36:52
![](https://img.aspxhome.com/file/2023/9/103239_0s.png)
Python实现App自动签到领取积分功能
2021-09-16 15:59:59
![](https://img.aspxhome.com/file/2023/1/95571_0s.jpg)
Pivot,信息组织的梦想之窗
2009-12-25 14:32:00
![](https://img.aspxhome.com/file/UploadPic/20101/11/pivot-01-87s.jpg)
自学MySql内置函数知识点总结
2024-01-23 11:19:04
asp如何同时处理数据库和页面错误?
2010-06-07 20:58:00
sqlserver 无法验证产品密匙的完美解决方案[测试通过]
2024-01-23 11:53:23
微软建议的ASP性能优化28条守则(1)
2008-02-22 16:54:00
![](https://img.aspxhome.com/file/UploadPic/up/2008032516342961.gif)
Python库functools示例详解
2021-03-10 07:01:27
揭秘SQL Server 2014有哪些新特性(1)-内存数据库
2024-01-26 05:42:47
![](https://img.aspxhome.com/file/2023/9/89699_0s.jpg)
python的PyPDF2实现pdf文件切割和合并
2023-02-07 19:57:39
![](https://img.aspxhome.com/file/2023/8/102968_0s.png)
Bootstrap Metronic完全响应式管理模板之菜单栏学习笔记
2023-08-17 10:58:20
![](https://img.aspxhome.com/file/2023/7/56047_0s.jpg)