Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run a pypy kernel in the Jupyter notebook?

Tags:

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?

like image 584
ericmjl Avatar asked Nov 22 '15 01:11

ericmjl


People also ask

What kernels are available for Jupyter?

5.1 Language support: kernels The Jupyter system supports over 100 programming languages (called “kernels” in the Jupyter ecosystem) including Python, Java, R, Julia, Matlab, Octave, Scheme, Processing, Scala, and many more.

Can you use multiple kernels within the same Jupyter Notebook?

SoS Notebook is an extension to Jupyter Notebook that allows the use of multiple kernels in one notebook. More importantly, it allows the exchange of data among subkernels so that you can, for example, preprocess data using Bash, analyze the processed data in Python, and plot the results in R.

Can we run pyqt5 in Jupyter Notebook?

The Qt console is a very lightweight application that largely feels like a terminal, but provides a number of enhancements only possible in a GUI, such as inline figures, proper multi-line editing with syntax highlighting, graphical calltips, and much more. The Qt console can use any Jupyter kernel.


Video Answer


2 Answers

Provided you have a system-wide / user installation of jupyter. You can follow:

pypy3 -m venv PyPy3 source PyPy3/bin/activate  # in POSIX, or... PyPy3\Scripts\activate.bat  # in Windows pypy3 -m pip install ipykernel ipython kernel install --user --name=PyPy3 

Now exit the virtual environment and verify installation:

jupyter kernelspec list 

Open Jupyter notebook or lab interface.

like image 131
jadelord Avatar answered Oct 18 '22 10:10

jadelord


You can install Jupyter with pypy:

pypy-pip install jupyter 

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

pypy-pip install --no-deps jupyter 

Than start with:

pypy-ipython notebook 

My pypy-ipython looks like this:

#!/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 a notebook:

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

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

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')()     ) 
like image 36
Mike Müller Avatar answered Oct 18 '22 12:10

Mike Müller