Cheng's Blog

  • About Me
  • Archive
  • feeds

Posts match “ IPython ” tag:

over 7 years ago

安装 iPython Notebook

平时很喜欢用iPython的Notebook功能来学习和实验python程序。今天在台新电脑上办公,所以需要重新安装一下。安装iPython有两种选择:

  1. 通过pip安装
  2. 安装Anaconda从而获得iPython (这个选择比较适合新手,推荐下载Anaconda安装包然后一键搞定)

这次主要介绍如何通过pip来安装。iPython是由很多模块组成的, 为了不漏装任何组件,我用了这个命令来安装所有组件:

$ pip install ipython[all]

安装成功后通过这命令来运行Notebook:

$ ipython notebook

之后有可能会弹出这个错误(你如果选择了用Anaconda的方式来安装也会碰到这个错误):

ValueError, 'unknown locale: %s' % localename

在StackOverflow上已经有人提出了解决方案,在命令行里找到.bash_profile 然后添加下面两行代码:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

然后别忘了重新载入.bash_profile让新添加的代码生效(注意两个点之间的空格):

$ . .bash_profile

之后再运行这个命令就可以在浏览器里看到iPython Notebook的界面了:

$ ipython notebook

iPython Notebook的工作原理是在本地启动一个服务器,你通过localhost:8888/tree 这个地址就可以连接到这个服务器上与之通信。从而实现在浏览器里写代码,传给本地服务器执行,然后本地服务器传回结果并在网页上呈现这个循环。

每次使用完Notebook,只关闭网页本身是不够的。需要在你启动Notebook的那个Terminal里输 Ctrl + c 然后确认,才能把服务器关闭。

  • IPython
  • January 14, 2015 21:44
  • Permalink
  • Comments
 
about 7 years ago

Insert image in iPython Notebook

<img src='image.png'>

The Markdown syntax won't work in this case, you have to use raw html like above.

Reference:
http://stackoverflow.com/questions/10628262/inserting-image-into-ipython-notebook-markdown

  • IPython
  • Python
  • March 08, 2015 18:22
  • Permalink
  • Comments
 
almost 7 years ago

Write Javascript in iPython Notebook

I have found a tool that allows you to write and test Javascript quickly in iPython Notebook. The tool is called IJavascript. The project page has a very detailed installation guide for differet OS.

To install it on Mac:

1) Install ijavascript itself via npm:

npm install -g ijavascript

2) Install the dependencies via pip:

sudo pip install --upgrade ipython jinja2 jsonschema pyzmq

3) to run:

ipython ijs

Here is a screenshot of it running:

  • javascript
  • Python
  • IPython
  • July 28, 2015 15:00
  • Permalink
  • Comments
 

Copyright © 2013 GuoCheng . Powered by Logdown.
Based on work at subtlepatterns.com.