1

EDITED

I'm very new to python and have a probably super basic question. I've installed Jupyter Notebook by installing anaconda which includes python 3 by default. Now I want to use an external toolbox which still works with python 2.7, so I'm trying to get e kernel with python 2.7 as suggested here. In the Anaconda Prompt I'm typing

python2 -m pip install ipykernel
python2 -m ipykernel install --user

But it says that it couldn't find the command "python2". Any idea?

5
  • You need to exit the Python interpreter to run bash commands Commented Sep 24, 2017 at 15:28
  • 1
    just wondering why are you still use python2? Commented Sep 24, 2017 at 15:29
  • 1
    Possible duplicate of Why does "pip install" inside Python raise a SyntaxError? Commented Sep 24, 2017 at 15:30
  • I edited some more info to my problem. I still don't know how to use python 2 in Jupyter Notebook, the reference to the similar question doesn't really help me either. Commented Sep 24, 2017 at 19:00
  • 1
    You need a Python2 conda environment, then you can install that kernel into Jupyter. Check the link you already have... It says "if using Conda"... But again, you need to exit python first to run those commands Commented Sep 24, 2017 at 19:34

3 Answers 3

2

I had the same issue. You can try starting jupyter-notebook from python2

$ python2 /path/to/jupyter-notebook

in my case running python2 /usr/bin/jupyter-notebook fixed the issue. enter image description here

shebang in my case

$ head -1 /usr/bin/jupyter-notebook
#!/usr/bin/python3.4
$
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried looking at the Jupyter Notebook homepage?

Just use

pip install jupyter

or

pip install jupyter --user

5 Comments

That page also says For new users, we highly recommend installing Anaconda.
Yes, but you can install it either way... You just have to download some separate packages as mentioned on the site.
No no, I installed Jupyter Notebook by installing anaconda as @cricket_007 suggested. But it comes with python 3 and I need python 2 for an external toolbox that I want to use, as it is only compatible with python 2 unfortunately.
@SvennoNito On the Anaconda homepage you can choose between python 2.7 and python 3.6 when downloading the installer? Homepage
I read somewhere else that I don't need to install Anacdona twice. I already managed to create a python 2.7 environment and to install a python 2 kernel for the Jupyter Notebook, I just wonder why the code above doesn't work for me.
0

I still don't know why it doesn't work, but i found out what worked instead. Using

conda create -n ipykernel_py2 python=2 ipykernel
activate ipykernel_py2    
python -m ipykernel install --user

in the Anaconda Prompt added the option to open a python 2 notebook in the Jupyter Notebook. Also I can change the Kernel now to python 2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.