0

Currently, I am working in a VM that does not have an internet connection.

I have Python2 installed installed on this machine and have been using it fine within Jupyter. I have installed Anaconda 3.6 and would like to create a kernel inside Jupyter for Python3 in addition to the Python2 Kernel that is present.

I have followed another stackexchange question: How do I add python3 kernel to jupyter (IPython)

and some documentation: https://ipython.readthedocs.io/en/latest/install/kernel_install.html#kernels-for-python-2-and-3

The command that is doing something, just not the right something is:

/path/to/kernel/env/bin/python -m ipykernel install

No matter where I point it, it installs another kernel, but with Python 2.7...

Any suggestions?

Qwerty
  • 35
  • 9
  • make sure you are running `python3 -m ipykernel install`. – AChampion Jun 22 '17 at 18:19
  • python3 is not recognized as a command, maybe that is where I am going wrong. How would I go about getting that recognized? – Qwerty Jun 22 '17 at 18:26
  • You shouldn't need to do `python3` if your Anaconda environment is Python 3. If you do `/path/to/kernel/env/bin/python --version` what does it say? – BrenBarn Jun 22 '17 at 18:43
  • That command gives me this: Python 3.6.1 :: Anaconda 4.4.0 (64-bit) – Qwerty Jun 22 '17 at 18:45
  • That is strange. How do you know it is installing another Python 2.7 kernel? Did you try giving the kernel an explicit name by doing something like `/path/to/env/bin/python -m ipykernel install --name py36 --display-name "Python 3.6"` (as described [here](https://ipython.readthedocs.io/en/latest/install/kernel_install.html#kernels-for-different-environments))? – BrenBarn Jun 22 '17 at 18:49
  • I have printed the version with import platform, platform.python_version() - I have also tried giving it an explicit name and it reverts to python2 – Qwerty Jun 22 '17 at 19:48
  • I am under the impression it is using the default python of 2.7 and not actually referencing the python 3.6 regardless of explicity telling it to. I think the only way around this may be to uninstall Python 2.7, but that may cause huge issues elsewhere... – Qwerty Jun 22 '17 at 21:11
  • 1
    Use `jupyter --paths` to determine where the kernels are being installed (`data`). And manually edit the `kernel.json` to point to right python. – AChampion Jun 22 '17 at 23:16
  • Is the behavior any different if, instead of passing the env path on the command line, you actually do `activate my_python3_env` and then do `python -m ipykernel install --name ...` etc. from the activated environment? – BrenBarn Jun 23 '17 at 03:13
  • @AChampion, I checked all paths brought up. There were 4 and there are 4 kernels active currently. One of the paths does not exist. One of the paths has python3 that I created and another kernel inside (could that be the problem?). The python3 kernel.json is referencing python 3. – Qwerty Jun 23 '17 at 13:27
  • @BrenBarn, I can't seem to activate as its saying it can not find the environment. – Qwerty Jun 23 '17 at 13:31
  • Okay, then it seems like something is messed up with your anaconda installation. Try to get that resolved before dealing with this ipykernel issue. If you do `conda info --envs` do you see your Python 3 environment listed? – BrenBarn Jun 23 '17 at 19:07
  • The python 3 environment is not listed, only anaconda2. – Qwerty Jun 26 '17 at 13:19
  • A coworker and I got it to work correctly today. I was using the jupyter defaulted to 2.7 when I have to specify the 3.6 jupyter. Once that is done, it works correctly. Thanks AChampion and BrenBarn for the help. – Qwerty Jun 26 '17 at 21:00

1 Answers1

0

The correct answer for my situation was to specify the python3 jupyter-notebook path instead of just using the default jupyter notebook.

Qwerty
  • 35
  • 9