Change IPython 3 for Python 3 kernel to python2 for cluster too

I have IPython 3 installed for Python 3 to work with Jupyterhub.

Now I can use laptops with the Python2 core because I created /usr/local/share/jupyter/kernels/python2/kernel.json

with:

 { "argv": ["python2", "-m", "IPython.kernel", "-f", "{connection_file}"], "display_name": "Python 2", "language": "python2" } 

Now I would also like to use IPython.parallel, but when I start the cluster it will automatically start the engines in Python 3, how can I change this to Python 2?

+6
source share
1 answer

I solved the problem with

sudo mkdir /etc/ipython/

sudo nano /etc/ipython/ipython_config.py

add the following lines:

  c = get_config() c.LocalControllerLauncher.controller_cmd = ['/usr/bin/python2', '-m', 'IPython.parallel.controller'] c.LocalEngineLauncher.engine_cmd = ['/usr/bin/python2', '-m', 'IPython.parallel.engine'] c.LocalEngineSetLauncher.engine_cmd = ['/usr/bin/python2', '-m', 'IPython.parallel.engine'] 

And now the engines should start with python2

EDIT for Jupyter 1.0 or IPython 4.0: Change to

 c = get_config() c.LocalControllerLauncher.controller_cmd = ['/usr/bin/python2', '-m', 'ipyparallel.controller'] c.LocalEngineLauncher.engine_cmd = ['/usr/bin/python2', '-m', 'ipyparallel.engine'] c.LocalEngineSetLauncher.engine_cmd = ['/usr/bin/python2', '-m', 'ipyparallel.engine'] 

and return the cluster tab: sudo mkdir / etc / jupyter /

 sudo nano /etc/jupyter/jupyter_notebook_config.py 

Add this:

 c.NotebookApp.server_extensions.append('ipyparallel.nbextension') 
+2
source

Source: https://habr.com/ru/post/985601/


All Articles