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. top 常用

    top -c 查看进程 同时 shift +m 内存倒序

  2. # 学号 20175223 《Java程序设计》第3周学习总结

    学号 20175223 <Java程序设计>第3周学习总结 教材学习内容总结 第四章要点: 要点1:面向对象三个性质:封装性.继承.多态: 要点2:类:类声明.类体.成员变量.方法.类的U ...

  3. Hadoop学习笔记01_Hadoop搭建

    想往大数据方向转, 难度肯定是有的. 基础知识肯定是要有的,如果是熟悉JAVA开发的人,转向应该优势大. 像我这样的,只有Linux基础以及简单的PHP基础的人,转向难度很大.但是事在人为,努力学习多 ...

  4. 理解微信小程序的生命周期和运行原理

    写微信小程序,他的生命周期不能不知道,不知道小程序就会出现各种bug而无法解决.小助君公众号带你学习小程序的生命周期和运行原理. 小程序由两大线程组成:负责界面的线程(view thread)和服务线 ...

  5. java中main函数的String[] args

    写java程序时main函数必须有一个字符串数组即String[] args 作用:用来获取用户从命令行输入的参数 如果main函数中不写字符串数组,则将会报错

  6. itextsharp报错PdfReader not opened with owner password

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

  7. 周强201771010141《面向对象程序设计Java》第八周学习总结

    一.理论知识学习部分 Java为了克服单继承的缺点,Java使用了接口,一个类可以实现一个或多个接口. 接口体中包含常量定义和方法定义,接口中只进行方法的声明,不提供方法的实现. 类似建立类的继承关系 ...

  8. 产品经理面试题——浅谈O2O

    分析:O2O也要分种类.      现在的O2O 已经是线上线下相互融合的阶段了,无论是线上体验,线下消费还是线下体验,线上下单.都已有比较成熟的模式.我对O2O的理解就是以消费者为中心,整合线上和线 ...

  9. Beta版——爱阅APP功能说明书

    爱阅APP功能说明书 一.引言 通过Alpha发布和一些用户的反馈信息,了解到我们APP存在的问题.针对这些问题我们做了一些修改.以下内容是Beta版的功能说明书. 二.工具 安卓手机 爱阅APP安装 ...

  10. hdu 1166 (单点更新+区间求和+裸题)

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submissi ...