2015-11-22 24 views
11

Mi sono sempre chiesto se fosse possibile eseguire PyPy nel taccuino Jupyter. Recentemente ho provato a installare PyPy sul mio computer locale, e ha funzionato molto bene: accelerazione 100X in una simulazione basata su agenti scritta in puro Python. Tuttavia, mi manca l'interattività nel taccuino Jupyter. È possibile far sì che il kernel IPython usi PyPy piuttosto che CPython?È possibile eseguire un kernel pypy nel notebook Jupyter?

risposta

6

È possibile installare Jupyter con PyPy:

pypy-pip install jupyter 

L'sono problemi su Mac OS X. Se l'installazione fallisce lamentando una su gnureadline. Prova questo:

pypy-pip install --no-deps jupyter 

Than iniziare con:

pypy-ipython notebook 

mio pypy-ipython assomiglia a questo:

#!/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 un quaderno:

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)]' 

Il notebook richiede Python 2.7 o 3.3+. PyPy per Python3.3 dovrebbe essere presto disponibile.

mio pypy-pip questo file eseguibile /usr/local/bin//pypy-pip con questo contenuto:

#!/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')() 
    ) 
+0

Grazie per la risposta, Mike! Come posso ottenere lo strumento 'pypy-pip'? Al momento ho già pip e setuptools installati per pypy e pypy3, configurati all'incirca nello stesso modo dell'anaconda Python (in una directory separata sotto la mia cartella home). – ericmjl

+2

Mi scuso per aver postato questo secondo veloce ... ma mi sono reso conto che posso fare 'pypy -m pip install package_name' o' pypy3 -m pip install package_name' solo dopo aver postato il mio commento. – ericmjl

+1

Aggiunto il contenuto di 'pypy-pip'. –

Problemi correlati