ref: https://stackoverflow.com/questions/53385448/how-can-i-manage-the-modules-for-python2-when-python3-installed-as-well-in-osx

I'm using OSX and I installed python3 with anaconda installed. In my OSX, there exists two versions of python, i.e. python2 and python3.

I managed the modules in anaconda which only affect modules in python3. But how can I manage(install, delete, update) the modules for python2?

I've checked some posts about 'python2 is at /usr/bin/python' . So it's ok to use python2 by '/usr/bin/python' without configuring alias. But, how can I manage(install, delete, update) the modules for python2 when python3 installed as well. In OSX.

Anaconda comes with a package and environment manager called conda. This is what you need to do:

Create a separate Python 2.7 environment, let's call it old and busted.

conda create --name old_and_busted python=2.7

Now switch to this environment:

conda activate old_and_busted

Verify it worked if you want:

python --version

Install some modules cool:

conda install flask

Bonus, use pip to install something cool in the same environment:

pip install flask

What environment are we in again?

conda env list

Let's check for that package:

conda list

Now this part is very important, make sure to do it often - go back to your Python 3 environment:

conda activate base

pipenv manages environments in a similar way. Anaconda specializes in packaging for scientific computing handling packaging non-python extensions (e. g. C, C++) dependencies well.

** Note on conda vs source for environment activation **

If conda activate does not work use source activate. This was changed in Anaconda 4.4.0.
If you have this in your .bash_profile (or .profile or other magical dotfile) you use source activate:

export PATH="$HOME/anaconda3/bin:$PATH"

If you have this updated code in your shell startup then you can use conda activate:

. $HOME/anaconda3/etc/profile.d/conda.sh
conda activate

How can I manage the modules for python2 when python3 installed as well. In OSX的更多相关文章

  1. python2 与 python3 urllib的互相对应关系

    urllib Python2 name Python3 nameurllib.urlopen() Deprecated. See urllib.request.urlopen() which mirr ...

  2. 在同一台电脑上同时安装Python2和Python3

    目前Python的两个版本Python2和Python3同时存在,且这两个版本同时在更新与维护. 到底是选择Python2还是选择Python3,取决于当前要使用的库.框架支持哪个版本. 例如:HTM ...

  3. python2与python3在windows下共存

    python有python2(工业版)和python3,有时候我们会希望电脑上既有python2也有python3,!假设我们已经安装好,python2和python3了, 接下来我们找到python ...

  4. Python2.7<-------->Python3.x

    版本差异 from __future__   Python2.7 Python3.x 除法 / // Unicode u''                                       ...

  5. 同时使用python2和Python3

    问题:thrift生成的是python2代码,之前使用的是Python3因此需要同时使用两个版本. 方案:将python3的可执行文件重命名为python3(默认为Python),这样使用pyhton ...

  6. python2 到 python3 转换工具 2to3

    windows系统下的使用方法: (1)将python安装包下的Tools/Scripts下面的2to3.py拷贝到需要转换文件目录中. (2)dos切换到需要转换的文件目录下,运行命令2to3.py ...

  7. windows下同时安装python2与python3

    由于python2与python3并不相互兼容,并且差别较大,所以有时需要同时安装,但在操作命令行时,怎么区别python2与python3呢? 1.下载并安装Python 2.7.9和Python ...

  8. 爬虫入门---Python2和Python3的不同

    Python强大的功能使得在写爬虫的时候显得十分的简单,但是Python2和Python3在这方面有了很多区别. 本人刚入门爬虫,所以先写一点小的不同. 以爬取韩寒的一篇博客为例子: 在Python2 ...

  9. python2 和python3共存下问题

    一.使用python2 or python3 1. 使用python2 $ python xxx.py 2. 使用python3 $ python3 xxx.py 二.脚本调用 /usr/bin/en ...

随机推荐

  1. cocos2d-x js 中创建node的方法

    1.精灵Sprite 一共4种创建方式 (1) 根据图片资源路径创建 1 2 3 4 //参数1:图片资源路径 var sprite1 = cc.Sprite.create("res/zif ...

  2. python笔记17-全局变量、局部变量

    在函数里面定义变量叫局部变量,它只能在函数里面用出了该函数外,就不能使用了在函数外面定义的变量,是全局变量,在函数内也可以使用 如果想在函数里面修改全局变量的值,那么要先用global关键字声明 要修 ...

  3. 2017-9-3模拟赛T1 卡片(card)

    题目 [题目描述] lrb 喜欢玩卡牌.他手上现在有n张牌,每张牌的颜色为红绿蓝中的一种.现在他有两种操作.一是可以将两张任意位置的不同色的牌换成一张第三种颜色的牌:二是可以将任意位置的两张相同颜色的 ...

  4. python自学第14天 类

    面向对象:世界万物,皆可分类:世界万物,皆为对象 只要是对象,就肯定属于某种品类. 只要是对象,就肯定有属性 类 对象 封装 继承 多态 一个接口,多种实现

  5. itextsharp报错PdfReader not opened with owner password

    itextSharp读取Pdf时报错:PdfReader not opened with owner password 报错原因:pdf文件被用户加密了. 解决办法:在创建pdfReader实例后,加 ...

  6. acrgis 解决矢量转栅格分辨率过大造成连续值变离散且出现空白

    目标:解决北京河流矢量polygon 转栅格的问题 设置栅格大小和影像一致30*30----结果发现,因为cell过大,原本连续的是矢量面变得不连续了,特别细的河流会出现间断(如下图所示): 1号 网 ...

  7. 神州数码多区域OSPF配置

    实验要求:掌握多区域OSPF配置 拓扑如下 R1 enable 进入特权模式 config 进入全局模式 hostname R1 修改名称 interface s0/1 进入端口 ip address ...

  8. TCP/IP笔记(1)

    TCP/IP 背景和介绍 上世纪 70 年代,随着计算机技术的发展,计算机使用者意识到:要想发挥计算机更大的作用,就要将世界各地的计算机连接起来.但是简单的连接是远远不够的,因为计算机之间无法沟通.因 ...

  9. 网络编程 多线程/socketserver模块/ threading.local

    线程:进程中负责程序执行的执行单元. 多线程:在1个进程中存在多个线程. 进程只是用来把资源集中在一起,而线程才是cpu上的执行单位. 每个进程都会默认有一个控制线程也叫作主线程. 进程之间是竞争关系 ...

  10. 关于WebAPI跨域踩到的一点坑

    最近在尝试前后端分离的WebAPI+AngularJS方案,在率先处理授权的时候,踩到了一点WebAPI跨域的坑,其实严格意义上来说也不算是坑吧,只是我自己对WebAPI不熟悉而已,这里我与大家分享一 ...