iPython与不同的env(使用anaconda) [英] iPython with different env (using anaconda)

查看:432
本文介绍了iPython与不同的env(使用anaconda)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用anaconda(称为python35)创建了一个带有python 3.5的新环境。我的根env指向python 2.7.11。我似乎无法使用这个新的env启动ipython,这就是我做的事情

I have just created a new env with python 3.5 using anaconda (called it python35). My root env points to python 2.7.11. I cant seem to launch ipython with this new env, here is what I did

1. in conda prompt, activate required env: activate python35
2. confirm the version: python --version
3. launch ipython: ipython notebook
4. open a notebook and do: import sys; print (sys.version)

步骤#2,返回3.5,但步骤#4总是给我2.7。 11,它像ipython一样从root env中获取python版本。我该如何解决。感谢您的帮助!

Step #2, returns 3.5 but step #4 always gives me 2.7.11, its like ipython is picking up python version from root env. How do I fix this. Thanks for any help!

这个问题是相关的,但我已经完成了它的建议。

This question is related but I have already done what it suggests.

推荐答案

AFAIK,anaconda(以及venv中)的不同环境由预先 env路径激活到 $ PATH 环境变量。这意味着,如果在env路径中找不到某个文件(例如 ipython )( $ PATH ),系统在 $ PATH 的后续条目中搜索它,并在根环境中找到它(保留在 $ PATH )。要修复此行为,您需要将自己的 ipython 副本安装到anaconda env:

AFAIK, different environments in anaconda (and in venv as well) are activated by prepending env path to $PATH environment variable. It means, that if some file (eg, ipython) is not found in env path (the first entry of $PATH), the system searches for it in consequent entries of $PATH and finds it in root environment (that stays in $PATH). To fix the behavior, you need to install its own copy of ipython to anaconda env:


  1. 在命令提示符下,激活环境: source activate python35 (或简单地激活python35 ,具体取决于操作系统)

  2. 在环境中,发出命令 conda install ipython-notebook

  1. In command prompt, activate the environment: source activate python35 (or simply activate python35, depending on the OS)
  2. While in environment, issue the command conda install ipython-notebook

这篇关于iPython与不同的env(使用anaconda)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆