1. 程式人生 > >virtualenvwrapper在macos 10.13.6中的使用

virtualenvwrapper在macos 10.13.6中的使用

nbsp per local copyright virt spa span https book

安裝虛擬環境參考 https://www.jianshu.com/p/0921fd4d4bca

列出安裝的軟件

pip list

virtualenv 15.1.0

virtualenv-clone 0.3.0

virtualenvwrapper 4.8.2

創建一個python3的虛擬環境

$mkvirtualenv --python=/usr/local/bin/python3 python_3

Running virtualenv with interpreter /usr/local/bin/python3

Using base prefix ‘/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7‘

/Library/Python/2.7/site-packages/virtualenv.py:1039: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module‘s documentation for alternative uses

import imp

New python executable in /Users/wangjun/.virtualenvs/python_3/bin/python3.7

Also creating executable in /Users/wangjun/.virtualenvs/python_3/bin/python

Installing setuptools, pip, wheel...done.

virtualenvwrapper.user_scripts creating /Users/wangjun/.virtualenvs/python_3/bin/predeactivate

virtualenvwrapper.user_scripts creating /Users/wangjun/.virtualenvs/python_3/bin/postdeactivate

virtualenvwrapper.user_scripts creating /Users/wangjun/.virtualenvs/python_3/bin/preactivate

virtualenvwrapper.user_scripts creating /Users/wangjun/.virtualenvs/python_3/bin/postactivate

virtualenvwrapper.user_scripts creating /Users/wangjun/.virtualenvs/python_3/bin/get_env_details

(python_3) wangjundeMacBook-Pro:~ wangjun$ python3

Python 3.7.0 (default, Sep 18 2018, 18:47:22)

[Clang 9.1.0 (clang-902.0.39.2)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import urllib

>>> import urllib.request

>>> urllib.request.urlopen("http://www.baidu.com")

<http.client.HTTPResponse object at 0x105a49ba8>

>>> exit()

顯示所有虛擬環境:workon

(python_3) wangjundeMacBook-Pro:~ wangjun$ workon

py2

python_3

(python_3) wangjundeMacBook-Pro:~ wangjun$

退出虛擬環境

$ deactivate

激活虛擬環境

workon python_3

(python_3) wangjundeMacBook-Pro:~ wangjun$

刪除虛擬環境

$ rmvirtualenv py2

Removing py2...

(python_3) wangjundeMacBook-Pro:~ wangjun$ workon

python_3

 

virtualenvwrapper在macos 10.13.6中的使用