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. python_6

    set 集合 {} 无序 s = {1,2,3,4,5} s = {}print(type(s)) # 空{}就是字典 s = {1,2,3,4,5}s = {1,2,3,'22','ss',Fals ...

  2. linux curl http get 请求中带有中文参数或者特殊字符处理

    在使用c++去请求http服务的时候,使用的是著名的curl工具提供的类库 libcurl,但是在使用的过程中发现,如果请求的参数值带了空格或者是参数是中文,会导致响应的回调函数没有被执行,虽然cur ...

  3. ionic3 自定义组件 滑动选择器 ion-multi-picker

    1.ionic3中有一个 ion-datatime 给大家选择时间提供了一个很方便的组件 效果如图  链接  https://ionicframework.com/docs/api/component ...

  4. [Go back to REDIS]

    Overview 内存中的数据结构存储系统,可以用作数据库.缓存和消息中间件. redis底层数据结构:跳跃表 [为什么选skiplist而不是red-black tree] 支持多种数据结构:Str ...

  5. Python 基于时间的进程通信

    import time from multiprocessing import Process,Event def f1(e): time.sleep(2) n = 100 print("子 ...

  6. 剑指Offer 52. 正则表达式匹配 (字符串)

    题目描述 请实现一个函数用来匹配包括'.'和'*'的正则表达式.模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次). 在本题中,匹配是指字符串的所有字符匹配整个模式 ...

  7. 剑指Offer 45. 扑克牌顺子 (其他)

    题目描述 LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决 ...

  8. Object.create(null)、Object.create({})、{} 三者创建对象的区别

    参考 1.先看看我们经常使用的{}创建的对象是什么样子的: var o = {a:1}; console.log(o) 从上图可以看到,新创建的对象继承了Object自身的方法,如hasOwnProp ...

  9. ecmall 移动端 微信分享

    /* 用户判断是否在微信端 */ $this->assign('isWeixin', isWeixin()); //isWeixin() 在系统核心基础类的ecmall.php里定义好了 是微信 ...

  10. Python学习二十八周(vue.js)

    一.指令 1.一个例子简单实用vue: 下载vue.js(这里实用1.0.21版本) 编写html代码: <!DOCTYPE html> <html lang="en&qu ...