Mac安装python-virtualenv与virtualenv使用

4 篇文章 0 订阅
1 篇文章 0 订阅
本文介绍了在Mac上安装virtualenv的步骤,并详细说明了如何创建和退出虚拟环境,帮助用户更好地管理Python项目依赖。
摘要由CSDN通过智能技术生成

一、安装virtualenv

sudo pip install virtualenv

安装成功后终端输入:

virtualenv

(py3env)resume develop % 

You must provide a DEST_DIR
Usage: virtualenv [OPTIONS] DEST_DIR

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         Increase verbosity.
  -q, --quiet           Decrease verbosity.
  -p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g.,
                        --python=python2.5 will use the python2.5 interpreter
                        to create the new environment.  The default is the
                        interpreter that virtualenv was installed with
                        (/usr/bin/python)
  --clear               Clear out the non-root install and start from scratch.
  --no-site-packages    DEPRECATED. Retained only for backward compatibility.
                        Not having access to global site-packages is now the
                        default behavior.
  --system-site-packages
                        Give the virtual environment access to the global
                        site-packages.
  --always-copy         Always copy files rather than symlinking.
  --unzip-setuptools    Unzip Setuptools when installing it.
  --relocatable         Make an EXISTING virtualenv environment relocatable.
                        This fixes up scripts and makes all .pth files
                        relative.
  --no-setuptools       Do not install setuptools (or pip) in the new
                        virtualenv.
  --no-pip              Do not install pip in the new virtualenv.
  --extra-search-dir=DIR
                        Directory to look for setuptools/pip distributions in.
                        This option can be used multiple times.
  --never-download      DEPRECATED. Retained only for backward compatibility.
                        This option has no effect. Virtualenv never downloads
                        pip or setuptools.
  --prompt=PROMPT       Provides an alternative prompt prefix for this

安装成功


二、安装python

sudo brew install python3
检测python是否安装成功


三、创建虚拟环境

virtualenv -p /usr/local/bin/python3 .virtualenv/py3env
virtualenv -p 安装python路径  虚拟环境存放路径


四、开启虚拟环境

source .virtualenv/py3env/bin/activate 

这时终端前方会有   (py3env) develop %  标志


五、若要关闭虚拟环境

终端输入:deactivate

此时终端前方py3env会消失



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值