前言:继续安装中,这节记录 mac 安装 python 虚拟环境,多版本共存...

1. 安装 pip -- python的包管理工具:

sudo easy_install pip 

安装成功,出现下面:

2. 安装完pip之后,就要安装 virtualenv:

sudo pip install virtualenv  # 卸载安装:sudo pip uninstall virtualenv

据说如果是用的macOS 10.11可能会出现以下的提示(我用的是macOS 10.13,也出现以下的提示):

 The directory '/Users/xxxx/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/xxxx/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

可以忽略,或者执行下面的命令(其实它已经在提示的最后建议要加上 -H):

sudo -H pip install virtualenv

3. 然后要安装virtualenvwrapper:

Virtaulenvwrapper 是 virtualenv 的扩展包,可以更方便地新增,删除,复制,切换虚拟环境。

sudo -H pip install virtualenvwrapper

安装成功如下:

据说,有人在安装的时候,遇到了这样的错误(我未遇到,未验证):

 Installing collected packages: six
Found existing installation: six 1.4.
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line , in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line , in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line , in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line , in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_uninstall.py", line , in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line , in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line , in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line , in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line , in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno ] Operation not permitted: '/tmp/pip-vyEme3-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

执行下面的命令,重新安装:

 sudo pip install pbr
sudo pip install --no-deps stevedore
sudo pip install --no-deps virtualenvwrapper

4. 创建虚拟环境:

source /usr/local/bin/virtualenvwrapper.sh

5. 让文件生效,并且要将命令写到 ~.bash_profile 里。

创建虚拟环境,指定python的版本,并将虚拟环境命名为python3

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

6. 创建好虚拟环境之后,会自动进入虚拟环境

退出虚拟环境的命令为 deactivate

虚拟环境的一些命令:

workon   会列出所有的虚拟环境

workon  [name]  会进入指定的虚拟环境

deactivate   退出当前的虚拟环境

mkvirtualenv  [name] 创建虚拟环境

rmvirtualenv  [name] 删除虚拟环境

参考:https://blog.csdn.net/blog_user_zk/article/details/72844452

mac 下 python 虚拟环境的安装和配置的更多相关文章

  1. mac环境下Python虚拟环境的安装和配置

    虚拟环境(virtualenv) 安装:在终端输入 pip install virtualenv 如果没安装pip会出现 pip: command not found,此时需要进行 sudo easy ...

  2. Python虚拟环境的安装和配置-virtualenv与windows下多个python版本共存

    Python虚拟环境的安装和配置-virtualenv与windows下多个python版本共存 windows下多个python版本共存 https://www.python.org/downloa ...

  3. ubuntu系统下Python虚拟环境的安装和使用

    ubuntu系统下Python虚拟环境的安装和使用        前言:进行python项目开发的时候,由于不同的项目需要使用不同的资源包和相关的配置,因此创建多个python虚拟环境,在虚拟环境下开 ...

  4. linux系统下Python虚拟环境的安装和使用

    前言:进行python项目开发的时候,由于不同的项目需要使用不同的资源包和相关的配置,因此创建多个python虚拟环境,在虚拟环境下开发就显得很有必要. 安装虚拟环境 步骤: 打开Linux终端(快捷 ...

  5. python为何需要虚拟环境--Python虚拟环境的安装和配置-virtualenv

    一 虚拟环境 virtual environment 它是一个虚拟化,从电脑独立开辟出来的环境.通俗的来讲,虚拟环境就是借助虚拟机docker来把一部分内容独立出来,我们把这部分独立出来的东西称作“容 ...

  6. ubuntu环境下python虚拟环境的安装

    一. 虚拟环境搭建 在开发中安装模块的方法: pip install 模块名称 之前我们安装模块都是直接在物理环境下安装,这种安装方法,后面一次安装的会覆盖掉前面一次安装的.那如果一台机器上面开发多个 ...

  7. MAC下go语言的安装和配置

    Mac下安装一些文件都是比较简单的.安装了brew以后,很多的程序只要一条命令就搞定了. brew install go 安装好go语言以后主要是配置go_path,和go_root的地址. go_r ...

  8. mac下,redis的安装与配置

    一.安装redis 1.到官网下载redis最新版本号,我下载的是3.0.3 http://redis.io/ 2.拷贝redis-3.0.3到/usr/local文件夹 3.解压缩sudo tar ...

  9. windows下python虚拟环境virtualenv安装和使用

    前面介绍了python在ubuntu16.04环境下,python的虚拟环境virtualenv的安装,下面介绍在windows环境下的安装和使用. 环境信息 操作系统:windows10 pytho ...

随机推荐

  1. 前端小记6——项目中常用的ES6方法

    现在很多功能用es5的方法也能实现功能,但es6提供的方法显得更为高效.记录下目前常用的几个方法. 1.字符包含 通过str.includes('a')来判断, 若str中包含a则结果为true,否则 ...

  2. STMS传输队列中的请求状态一直是Running不能结束

    通过STMS传输请求时,遇到了如下问题: STMS传输请求,不论等多久的时间,请求状态一直是running,不能结束.但检查传输的内容时,发现CHANGE REQUEST包含的内容已经传输到目标Cli ...

  3. Java总结 - List实现类ArrayList&LinkedList

    本文是根据源码进行学习的,如果我有什么理解不对的地方请多指正,谢谢您 上面基本就是List集合类的类图关系了,图中省略掉了比如Cloneable等标记接口,那么List分别具体的主要实现类有:Arra ...

  4. Jack Straws POJ - 1127 (简单几何计算 + 并查集)

    In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...

  5. Codeforces Round #460 (Div. 2)-C. Seat Arrangements

    C. Seat Arrangements time limit per test1 second memory limit per test256 megabytes Problem Descript ...

  6. HDU 3896 Greatest TC 双连通分量

    题意 给一个连通的无向图,有两种询问: \(a, b, c, d\),问如果删掉\(c,d\)之间的边,\(a,b\)之间是否还连通 \(a, b, c\),问如果删掉顶点\(c\),\(a,b\)之 ...

  7. Java开发配置

    http://www.runoob.com/java/java-environment-setup.html

  8. SSRS 报表管理器 http://localhost/Reports HTTP500 内部错误处理过程

    原文地址:http://www.cnblogs.com/zzry/p/5716056.html 安装了很多机器的sqlserverBI 组件 初始安装配置下 浏览报表管理器 http://localh ...

  9. App 设计技巧

    http://www.360doc.com/content/14/1120/18/21412_426730809.shtml http://veryui.diandian.com/post/2013- ...

  10. 【Container With Most Water】cpp

    题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...