Reputation: 31
I have jupyter notebook installed on Mac with Python 3 Kernel. I tried to install a Kernel for Python 2 using command: python2 -m pip install ipykernel
, but got the following error:
Collecting ipykernel
Using cached ipykernel-4.6.1-py2-none-any.whl
Collecting jupyter-client (from ipykernel)
Using cached jupyter_client-5.1.0-py2.py3-none-any.whl
Collecting tornado>=4.0 (from ipykernel)
Using cached tornado-4.5.1.tar.gz
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, map
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/__init__.py", line 160, in <module>
monkey.patch_all()
File "/usr/local/lib/python2.7/site-packages/setuptools/setuptools/monkey.py", line 48, in patch_all
distutils.core.Command = setuptools.Command
AttributeError: 'module' object has no attribute 'Command'
Could anyone tell me where the problem is and how to install the kernel for python 2?
Upvotes: 1
Views: 840
Reputation: 5310
Assuming that you are running Anaconda I think that entering the following commands into your terminal may work
1) Use create a Python 2.7 conda env
conda create -n python2 python=2.7
2) Activate your new env from the terminal.
source activate python2
3) Install ipykernel into the python2 env
pip install ipykernel
4) Install the python2 kernel into ipython
ipython kernel install --name python2
If you are not running Anaconda try this tutorial; Create isolated Jupyter ipython kernels with pyenv and virtualenv
Please comment below if you are still having issues.
Upvotes: 1