是否可以在Jupyter笔记本中运行pypy内核? [英] Is it possible to run a pypy kernel in the Jupyter notebook?

查看:274
本文介绍了是否可以在Jupyter笔记本中运行pypy内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直想知道是否有可能在Jupyter笔记本中运行PyPy.我最近尝试在本地计算机上安装PyPy,并且运行得非常好-使用纯Python编写的基于代理的仿真速度提高了100倍.但是,我错过了Jupyter笔记本中的交互性.是否可以使IPython内核使用PyPy而不是CPython?

I have always wondered if it were possible to run PyPy in the Jupyter notebook. I recently tried installing PyPy on my local machine, and it ran really well - 100X speedup in an agent-based simulation written in pure Python. However, I miss the interactivity in the Jupyter notebook. Is it possible to make the IPython kernel use PyPy rather than CPython?

推荐答案

您可以使用pypy安装Jupyter:

You can install Jupyter with pypy:

pypy-pip install jupyter

这是Mac OS X上的问题.如果安装失败,则抱怨gnureadline.试试这个:

The are problems on Mac OS X. If the install fails complaining a about gnureadline. Try this:

pypy-pip install --no-deps jupyter

比开始于:

pypy-ipython notebook

我的pypy-ipython看起来像这样:

#!/usr/local/bin/pypy

# -*- coding: utf-8 -*-
import re
import sys

from IPython import start_ipython

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(start_ipython())

在笔记本电脑上:

In [1]: import sys

In [2]: sys.version

Out[2]:

'2.7.9 (295ee98b6928, May 31 2015, 07:28:49)\n[PyPy 2.6.0 with GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)]'

笔记本需要Python 2.7或3.3+.适用于Python3.3的PyPy应该很快就会发布.

The notebook requires Python 2.7 or 3.3+. PyPy for Python3.3 should be out soon.

我的pypy-pip此可执行文件/usr/local/bin//pypy-pip具有以下内容:

My pypy-pip this executable file /usr/local/bin//pypy-pip with this content:

#!/usr/local/bin/pypy
# EASY-INSTALL-ENTRY-SCRIPT: 'pip','console_scripts','pip'
__requires__ = 'pip'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('pip', 'console_scripts', 'pip')()
    )

这篇关于是否可以在Jupyter笔记本中运行pypy内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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