Jupyter Notebook only has Python [conda root] and Python [default] kernels - python

I followed all the steps outlined in the other Python [root] posts, but still cannot get the python2 and python3 kernels to show up.
Here is what my Jupyter notebook shows:
and here is the startup log:
I have Anaconda3 installed (the 3.5 version).
How do I get the python2 and python3 kernels to show up?

I have the similar situation as yours and I solved it through:
Switch to the conda env you wanna show in Jupyter notebook
>>> source activate conda_env_name
Install/reinstall Jupyter under this env using:
(conda_env_name)>>> conda install jupyter
You should be able to see your env under Jypyter Kernel->Change kernels lists (this is my first stackoverflow answer, hope it helps you)

I had a similar issue but i had python 2.7.12 installed from anaconda and the default one came with Mac is 2.7.10.
When i open jupiter notebook, i used to get Python[conda root] and Python[default], after lot of struggling i did the following
conda update conda
conda uninstall ipython
conda install jupyter
now i see only 'Python 2' in my Jupiter notebook
hope this helps

I was stucked like you, and the solution is easy:
For more information: https://docs.continuum.io/anaconda/jupyter-notebook-extensions#notebook-conda
In the HOME of jupiter Notebook you will find: Files, Running, Clusters and Conda
Select Conda
Then there is a space for the conda environments, there is a sign +, clic on it to add a new environment, here you can select conda 2 or 3, depends on you, and give a name, it could be the same name Conda 3.
After that you refresh environment list, and then close jupyter notebook.
Finally, open it again, and it should works.

Related

Jupyter is not using my virtual environment in VSCode

I'm currently having problems getting Jupyter to connect to my kernel that I made using my virtualenv.
Here's what I did:
I first created my virtual environment by doing:
python3 -m venv venv
Then I activated the venv in my terminal, and installed the packages that I needed for my project:
pip install numpy pandas matplotlib ipykernel jupyter jupyterlab
Then I created a kernel from my venv so that Jupyter can use by doing:
python3 -m ipykernel install --user --name=python_data_analytics
Afterwards, I tried to get VSCode to use my venv and I got it to use the interpreter at bin/ipython3 of my venv. As for Jupyter, I got it to use the kernel I made from a dropdown menu.
Then when I tried to execute the first cell of my notebook to import my libraries, Python says that it can't find my libraries.
Here's a screenshot of the end result:
It seems that Jupyter is not using the virtual environment that I made and it's falling back to the system's interpreter. I'm not sure how should I go about fixing this problem. Any help is much appreciated. Thank you.
I'm not sure, but in the left bottom option, where there is a label called "Python 3.9.5..." you can select your desired environment.

Installing a ipykernel and running jupyter notebook inside a virtual env - not using conda

I've hit a dead end trying to solve/debug this issue which doesn't seem like it should be that difficult.
I'm working in Pycharm IDE (not the professional) and I'm working inside a virtual environment let's call it pythonProject and I want to be able to run launch a jupyter notebook in this environment so that it can pick up all the python packages i've installed and configured for this environment.
As I understand it from the documentation, these are the steps I need to take.
My terminal prompt statement:
(pythonProject) oliver#oliver-u20:~/pythonProject$
commands:
python3 -m pip install ipykernel
python3 -m pip install notebook
python3 -m ipykernel install --user --name pythonProject --display-name "Python (pythonProject)"
jupyter notebook
But when I load jupyter notebook, it only shows python3 under kernels.
I tried outputting
jupyter kernelspec list
And get only the base kernel which suggests from this that it's not finding my kernelspec, but I can't seem to figure from the documentation what i'm supposed to do.
Am I missing something?
Ok so I've solved this.
I think there was an install issue with jupyter.
I tried reproducing this in a completely new project and venv and could get the kernel showing.
In the project and venv where I still couldn't, I noticed a discrepancy in the output of my jupyter --paths
In the working venv I could see under data
/home/oliver/.local/share/jupyter
Which is where the kernels I installed are located.
However in the project that wasn't working there was instead:
/home/oliver/snap/jupyter/6/.local/share/jupyter
I'm guessing this snap path is from how I originally installed jupyter on my Ubuntu via the app store - seemed sensible at the time.
So I uninstalled jupyter, restarted my venv and the jupyter --paths has magically changed so that
/home/oliver/.local/share/jupyter
is present and when I start a jupyter notebook at the command line with
jupyter notebook
I can see all my kernels showing!
I found this quite difficult to debug with the documentation and command help outputs so hope someone else finds this useful.

Jupyter Notebook Import Problems

I have problems importing python packages into Jupyter Notebooks. When I open notebooks from the anaconda prompt, nothing can be imported as shown below.
import problem 1
When I open Jupyter Notebook through the anaconda navigator. Most of the module imports work apart from pandas-datareader.
import problem 2
I do not know why pandas-datareader doesn't work because according to prompt it's installed but according to the list of packages in the navigator it is not (unless it's part of pandas).
prompt
navigator
Please help. Thank you.
Two suggestions:
Explicitly make a kernel from your env. Activate the env (e.g. with source activate env) then try:
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
Ref
Restart the notebook, and look for a new option in the kernels dropdown
Second suggestion:
Import datareader before importing datareader.anything, and repeat that pattern across the notebook for all imports.
Please try in your anaconda prompt
for python 2:
pip install matplotlib
for python 3:
pip3 install matplotlib
and use anaconda prompt to open jupyter notebook and see.
Hope it can help you.
You can also just do
#1 if you have environment activate it
conda activate yourenvname
#2 check if your libraries are there
conda list
#3 make a clean kernel
python -m ipykernel install --user
#4 open notebook or lab
jupyter notebook

Ipython notebook - Create a new notebook (Python conda or default Python)

I have installed the latest version of Anaconda on my Ubuntu Linux virtual machine.
I successfully launched Jupyter in my browser using the following command : ipython notebook .
But when I want to create a new notebook, I have to choose between Python [conda root] and Python [default].
So, what are the differences between them? Which one to choose to create a new Notebook?
(I want to use Jupyter to work with Apache Spark)
Thank you.
// Update 22/10/2016
I created a new Environment python2 using : conda create -n python2 python=2.7 anaconda and I activate this new one : source activate python2.
When I list all environments : $ conda info --envs, I see these two lines :
python2 * /home/opentuto/anaconda2/envs/python2
root /home/opentuto/anaconda2
Now, my notebook, look like this :
Any solution!!?
Python [conda root] and Python [default].
What you are seeing are notebook kernels that you can use to create notebooks. The kernels listed are dependent on anaconda environments that you create and kernels installed. You see only default and conda root, because I'm assuming that you have simply installed the newest version of Anaconda for python 2.7 or 3.5. When installing Anaconda, it creates a root virtual environment and you can change the default environment based on environments that you have set up.
See the following for more information related to your question:
How do I add python3 kernel to jupyter (IPython)
https://github.com/jupyter/notebook/issues/1716
Jupyter and Apache Spark
I recommend setting up jupyter and spark in the following manner w/ your .profile.
export SPARK_PATH=~/...
export PYSPARK_DRIVER_PYTHON="jupyter"
export PYSPARK_DRIVER_PYTHON_OPTS="notebook"
After sourcing these variables you can call $ ./bin/pyspark and you'll have a spark context in a jupyter notebook.
The first approach is removing the extension... not recommanded.
The second approach is to just disable the extensions...recommanded
you can do something like this:
python -m nb_conda_kernels.install --disable --prefix=<ENV_PREFIX>
jupyter-nbextension disable nb_conda --py --sys-prefix
jupyter-serverextension disable nb_conda --py --sys-prefix
In this case, you just disable nb_conda_kernels and nb_conda that depend on the first one, but still keep the other ones active.
NOTE: Replace ENV_PREFIX with your root environment or another conda environment where the extensions have been installed.

After installing anaconda - command not found: jupyter

I have installed anaconda on my MAC laptop, and tried to run jupyter notebook to install it, but I get error jupyter command not found.
You need to activate your conda environment (source bin/activate) and then do
$ pip install jupyter # Alternatively, you can do `conda install jupyter`
$ jupyter notebook # to actually run the notebook server
Add $HOME/anaconda3/bin to your $PATH and jupyter-notebook should work. There are a ton of other binaries you can lookup in that folder as well.
export PATH=$HOME/anaconda3/bin:$PATH
then
jupyter-notebook
#ffledgling anwser did not work for me. What did solve was to install jupyter using conda:
conda install jupyter
That did the trick. Right after the installation finished I went with
jupyter notebook
as my next command and saw the server setup and the browser page opening.
I had this same problem on my Mac OS. I'm also new to Python, so forgive me if this is an obvious solution.
What solved it for me was installing Python with the 'install for me only' option rather than the hard-drive option. If it tells you you can't, then reselect it. After that, the command jupyter notebook opened without a problem.
Hope it can help someone!
How to
It could be as simple as opening a new Terminal window.
For Windows
After you can successfully run conda from powershell, you can install jupyter with: conda install jupyter command. Then re-open powershell and run conda run jupyter notebook.
If your issue is happening after running conda install jupyter, you can use conda init zsh to configure the ~/.zshrc automatically so that when you just type jupyter notebook on terminal, it can find it.
I ran into the same problem try this instead
jupyter-notebook
I had the same issue on Mac. I am using Miniconda
Opened ~/.zshrc profile on nano as, nano ~/.zshrc
and added the location of miniconda on my mac as the last line of the ~/.zshrc as:
export PATH="/usr/local/Caskroom/miniconda/base/bin:$PATH"
solves the issue easily.
Open a new terminal and try again, it worked for me. This is written somewhere in the installation guide "For this change to become active, you have to open a new terminal."
If it's a fresh installation. Close the the terminal and re-open
You don't have to install jupyter explicitly. Anaconda does for you.
Ensure the environment is activated first.
If you selected Yes when prompted "Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no]" during installation, prepend your commands with conda
mycomp#55:~$ conda activate
(base) mycomp#55:~$ jupyter notebook
After installing Anaconda on windows 10, you can use Anaconda prompt from start menu to activate a conda enabled terminal window.
You can run Jupyter from that window using:
jupyter notebook
You should first have conda in your PATH environment. You can achieve it taking a look on this answer.
Now you just need to run jupyter notebook.

Categories

Resources