macOS: 在virtualenv中激活python 3环境 https://coldfunction.com/feng92/p/ao
macOS默认是Python 2.7。所以需要先安装Python 3.
brew install python3
安装完毕后可以用过python3 -V
来验证。 经过验证,只需要走到这一步就可以安装好Python 3了。如果出现问题,可能是mac ruby版本过低,解决方案升级ruby:http://blog.youkuaiyun.com/ylgwhyh/article/details/78363572
在使用pip安装包时如果失败,可以尝试用pip不同版本试一试,比如pip3.6。
然后安装virtualenv:
pip install virtualenv
完毕后。创建一个基于Python 3的虚拟目录:
virtualenv -p python3 app
激活目录:
source bin/activate
输出:
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct 3 2017, 00:32:08)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
OK了!