Jupyter lab cannot connect to a kernel of a pipenv environment - jupyter-lab

I have python 3.8.5 installed with conda (miniconda). Jupyter lab is installed in the 'base' environment. I created a project and its virtual environment (fibonacci-6zMY4jHo) with 'pipenv'. To add the fibonacci-6zMY4jHo as a kernel into Jupyter lab, I did the following:
activated fibonacci-6zMY4jHo:
pipenv shell
installed ipykernel:
pipenv install ipykernel
Added fibonacci-6zMY4jHo to jupyter lab:
ipython kernel install --user --name=fibonacci-6zMY4jHo
Next:I run jupyter lab from the base environmnet. The list of kernels shows fibonacci-6zMY4jHo, but when I select it, jupter is not able to connect to it.
Any idea what is wrong?

Related

Trying to make sense of Python/Jupyter environment on MacOS

Background: while running Jupyter Notebook a new import was failing even though the library was installing successfully using pip3. Some of the set up for the code I was running was done in PyCharm which was using a virtual Python 3.8.2 environment. The failing import library is in the virtual environment so why isn't Jupyter seeing it?
I went looking and found that there are multiple versions of Python installed:
/Library/Python/2.7
/Library/Frameworks/Python.framework/Versions/3.8
/usr/local/bin/python3
/usr/local/bin/python3.8
/usr/local/bin/jupyter (included this in case it clarifies things)
/usr/bin/python
/usr/bin/python3
/usr/local/Cellar/python/3.7.6_1
/Users/xxx/anaconda3/bin/python3.7 (anaconda was uninstalled months ago so why is this still here?)
/Users/xxx/git/moat-ds/venv/lib/python3.8
I have installed pyenv and virtualenv and tried (unsuccessfully) to sort things out through this and similar articles. But all of this has only left me with questions:
what are these different directories doing?
when launched what is Jupyter notebook using for 'python 3' kernel?
where are the python packages stored when I run pip3 at the CLI (in pycharm packages are put in the \venv folder but otherwise?)
installing jupyter with pip from pyenv fixed my problem
brew uninstall jupyter
pip install jupyter
and after restarting your console it should be pyenv's jupyter
After trying #Akbar30bill's answer without success I did brew doctor and restarted my terminal and tried again and it worked. Wasn't linked correctly or something.

Using a Conda Environment in Jupyter via Miniconda

Has anyone found a way to successfully set up an environment for a jupyter notebook without having the full version of Anaconda installed on your system? I am using Miniconda and have been unable to use a conda environment with the jupyter notebook platform. Note that with Miniconda source activate myenv will not work.
I also tried using ipykernel which did successfully get an environment to appear in my notebook (via the command: python -m ipykernel install --user --name myenv). However, this environment is still made as a copy of my base environment. Commands similar to conda create -n test_env python=3.7 don't seem to be compatible with ipykernel unless I am missing something.
You don't need to run ipython from the environment you are adding.
Since you've got an environment with jupyter, lets call that Jenv.
go to your miniconda install location
Scripts/activate Jenv
conda create -n SomeOther_vEnv python=3.6.8 whateverPackagesYouWant
python -m ipykernel install --sys-prefix --name SomeOther_vEnv --display-name "foo"
Now jupyter when started from your Jenv should see "foo". You can't start jupyter from foo, but you can use it in a jupyter server started from Jenv. (unless whateverPackagesYouWant included jupyter of course)

Execute an existing jupyter notebook on an anaconda Virtual environment

I have an existing Jupyter notebook and I need to execute it an anaconda environment. I add the conda environment to jupyter notebook by executing the following commands:
conda install ipykernel
python -m ipykernel install --user --name myenv
Now, I can create a new jupyter notebook under the conda myenv.
The problem is how to execute an existing jupyter notebook with myenv? I can do it by copying the content to a new one but is there any other method?
We have just change the kernel under kernel->change kernel

How to run Jupyter Notebook without Anaconda on Ubuntu?

There is a lot of information available to run Jupyter Notebook with Anaconda but could not find any info to run Jupyter without Anaconda.
Any pointer would be much appreciated!
Basically the process is as follows:
pip3 install --upgrade pip
pip3 install jupyter
jupyter notebook # run notebook
Run a specific notebook:
jupyter notebook notebook.ipynb
Using custom IP or port:
jupyter notebook --port 9999
No browser:
jupyter notebook --no-browser
Help:
jupyter notebook --help
Answer from the following sources:
SOURCE 1
SOURCE 2
See Gordon Ball's Jupyter PPA, the most actively maintained Jupyter PPA as of this writing with support for both Ubuntu 16.04 and 18.04 (LTS).
Installation: It's a Ball
Thanks to Gordon's intrepid efforts, installation of Jupyter under Ubuntu trivially reduces to:
sudo add-apt-repository ppa:chronitis/jupyter
sudo apt-get update
sudo apt-get install jupyter
Doing so installs the jupyter metapackage, providing:
A standard collection of Jupyter packages published by this PPA, including:
Jupyter's core and client libraries.
Jupyter's console interface.
Jupyter's web-based notebook.
Tools for working with and converting notebook (ipynb) files.
The Python3 computational kernel.
The /usr/bin/jupyter executable.
As W. Dodge's pip-based solution details, the browser-based Jupyter Notebook UI may then be launched from a terminal as follows – where '/home/my_username/my_notebooks' should be replaced with the absolute path of the top-level directory containing all of your Jupyter notebook files:
jupyter notebook --notebook-dir='/home/my_username/my_notebooks'
Why Not Acanaconda or pip?
For Debian-based Linux distributions, the optimal solution is a Debian-based personal package archive (PPA). All other answers propose Debian-agnostic solutions (e.g., Anaconda, pip), which circumvent the system-wide APT package manager and hence are non-ideal.
Installing Jupyter via this or another PPA guarantees automatic updates to both Jupyter and its constellation of dependencies. Installing Jupyter via either Anaconda or pip requires manual updates to both on an ongoing basis – a constant thorn in the side that you can probably do without.
In short, PPA >>>> Anaconda >> pip.
There are two ways to install Jupyter-Notebook in Ubuntu. One is using Anaconda, the other using pip. Please go through the below added link for details.
http://jupyter.readthedocs.io/en/latest/install.html

How to change kernel when Jupyter notebook shows only one Python

I need to change the kernel to point it to miniconda version of Python, but Jupyter Notebook shows only one "Python 3" under Kernel-> Change Kernel.
Any idea how to get Jupyter notebook to show the additional one installed?
You can have a look at this and install the required kernel
https://ipython.readthedocs.io/en/latest/install/kernel_install.html
If you want to manually configure (add) Python 2.7 environment, try this:
conda create -n py27 python=2.7
conda activate py27
conda install notebook ipykernel
ipython kernel install --user

Resources