并行打开IPython Notebook 2.7和3.4 [英] Open IPython Notebook 2.7 and 3.4 in Parallel

查看:191
本文介绍了并行打开IPython Notebook 2.7和3.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了SO,但没有找到我正在尝试做的明确答案。如果答案已经存在,我会很感激URL的传递。供参考:我是运行多个Python版本的新手,可以通过两个解释器运行代码。我在Windows 7上,并使用了anaconda发行版。

I've searched through SO, but haven't found a clear answer to what I'm trying to do. If the answer already exists, I'd appreciate a pass-along of the URL. For reference: I'm new to running multiple Python versions, and can run code through both interpreters. I'm on Windows 7, and used the anaconda distribution.

在我的 cmd 中,我激活了Python2 .7默认。要访问Python2.7和Python3.4,我分别使用 python py -3 。我希望能够并行打开2.7和3.4的IPython浏览器笔记本,但不确定命令的外观/如何确定哪个浏览器窗口正在使用哪个解释器。

In my cmd, I've activated Python2.7 as default. To access Python2.7 and Python3.4, I use python and py -3 respectively. I'd like to be able to open IPython browser notebooks for 2.7 and 3.4 in parallel, but am not sure how the command would look/how to determine which browser window is using which interpreter.

来自@Jonas Buckner对如何在Anaconda 2.0中使用Python 3.4激活Ipython Notebook和QT控制台,似乎我可以指定端口。我的问题是,我如何知道哪个端口#与每个版本相关联?这是固定的,还是有某种方法可以确定哪个端口?

From @Jonas Buckner's comment on How to activate Ipython Notebook and QT Console with Python 3.4 in Anaconda 2.0, it seems that I can specify the port. My question is, how do I know which port # is associated with each version? Is this fixed, or is there some way I can determine which port?

ipython笔记本无法启动提到 ipython vs ipython3 ,我更喜欢,到端口方法。但是,当我尝试 ipython3 notebook 时,我得到:

ipython notebook not launching mentions ipython vs ipython3, which I would really prefer, to the port method. However, when I try ipython3 notebook, I get:

'ipython3' is not recognized as an internal or external command, operable program, or batch file.

是否可以设置别名?如果是这样,怎么样?

Is it possible to set up an alias? If so, how?

从上面重申,一旦我同时打开笔记本,有没有办法告诉哪个笔记本是哪个版本?

To reiterate from above, once I've opened notebooks in parallel, is there a way for me to tell which notebook is which version?

提前致谢!

推荐答案

你可以指定端口,所以选择用于每个版本的端口号; python2与python3没有预定义的端口。

You can specify the port, so you choose the port number to use for each version; there are no predefined ports for python2 vs python3.

例如:

ipython notebook --port=10000

将在端口上使用默认的python解释器运行IPython 10000 。然后,您可以通过转到 http:// localhost:10000 / tree 连接到该笔记本。

will run IPython, using the default python interpreter, on port 10000. You can then connect to that notebook by going to http://localhost:10000/tree.

说出来 ipython2 使用python2.7启动IPython,而 ipython3 使用python3.4启动IPython,您可以使用以下命令运行两个IPythons:

Say that ipython2 launches IPython with python2.7 while ipython3 launches IPython with python3.4 you can run both IPythons with the commands:

ipython2 notebook --port=27272
ipython3 notebook --port=34343

如果页面的网址以 localhost:27272 开头,那么笔记本正在运行如果URL以 localhost:34343 开头,那么笔记本正在运行python 3.4。

If the URL of a page starts with localhost:27272 then the notebook is running python 2.7 while if the URL starts with localhost:34343 then the notebook is running python 3.4.

请注意,这本身就有 nothing 来处理不同的python版本。
您可以使用相同的解释器在不同的端口上运行两个IPython实例。

Note that this, by itself, has nothing to do with different python versions. You can run two IPython instances on different ports using the same interpreter.

如果要使用特定的解释器启动IPython,可以将其作为模块启动使用 -m 开关:

If you want to launch IPython with a specific interpreter you can launch it as a module using the -m switch:

python2.7 -m IPython notebook --port=27272
python3.4 -m IPython notebook --port=34343

因此您不需要将 ipython ipython3 作为已识别的命令。您只需要能够运行两个不同的解释器。

so you don't need to have ipython or ipython3 as recognized commands. You simply need to be able to run the two different interpreters.

再次:要了解您正在使用的解释器版本,您只需查看端口号即可。 URL。或者您可以在口译员中检查 sys.version_info

Again: to understand which version of the interpreter you are using you can simply look at the port number in the URL. Or you can check sys.version_info in the interpreter.

如果您经常这样做,您可能有兴趣将端口号设置放在配置文件中。我不知道是否可以有两个不同的配置文件,一个用于python2,另一个用于python3。但是,在文件中,您可以检查版本并设置正确的端口号。

If you have to do this often you may be interested in putting the port number setting in a configuration file. I don't know whether it's possible to have two different configuration files, one for python2 and one for python3. However, inside the file, you can check the version and set the right port number.

这篇关于并行打开IPython Notebook 2.7和3.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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