Python Can't Connect to Kernel - python

My Jupyter Notebook will say connecting to kernel before not being able to make a connection.
To correct this I run.
python -m pip --proxy http://my_proxy_chain install --upgrade notebook
But while installing that, while it's collecting pywinpty>=1.1.0, I get:
ERROR: No matching distribution found for maturin<0.13,>=0.12.6
What troubleshooting steps should I attempt to get jupyter notebook talking to the kernel? I already installed maturin after getting this error - but that does not change the effect of getting it when I try to upgrade my notebook.

Try these steps;
create new environment using venv or conda env create -name <YOUR_ENV_NAME>
install dependancies. (You can even use pip install -r requirements.txt
for the jupyter kernel setup;
pip3 install jupyter ipykernel
python3 -m ipykernel install --user --name=new_kernel
new_kernel is the name of the kernel you need to select in the Jupyter notebook

Related

SageMath can't find jupyterthemes

I am running SageMath in MacOS with the built-in Jupyter notebook.
I have tried the following installation
(1) in terminal
sage -pip install jupyterthemes
(2) inside the jupyter notebook
!pip install jupyterthemes
!pip3 install jupyterthemes
!python3 -m pip install jupyterthemes
But in any case, running !jt in the notebook always returns
zsh:1: command not found: jt
I wonder how to make it work?

change python version in jupyter notebook

I am using jupyter notebook and jupyter lab through jupyter hub.
Currently, the python version recognized by jupyter is 3.6.8.
I want to set the python version to 3.7.3.
The python version installed on the server is as follows. (/usr/bin/python*)
The jupyter notebook kernel is set as follows in /usr/local/share/jupyter/kernels/python3/kernel.json
If you change the argv path to '/usr/bin/python3' or '/usr/bin/python3.7', the kernel is busy and the connection is not made. TT
It works well only when argv path is '/usr/bin/python 3.6'.
Setting Code
sudo apt-get install python3-pip
sudo pip3 install ipykernel
sudo jupyter kernelspec install-self
as this post says, you need to create a new kernel and this website shows how to do it
I solved it by reinstalling the below packages. thank you.
pip3 install tornado==5.1.1
pip3 install notebook==5.7.4```

Issue with Jupyter notebook and virtual environment pip

I have created a virtual environment using the following commands:
python3 -m venv venv
.\venv\Scripts\activate.bat
pip3 install ipykernel
pip3 install jupyter
python3 -m ipykernel install --user --name=venv
I have created a Jupyter notebook using the venv that I created, but when I install a package in the virtual environment, it is not recognised in the notebook.
For example, I tried to install pandas using pip3 install pandas, but when I try and import it into my notebook I get the error ModuleNotFoundError: No module named 'pandas'
The module has installed in the right place venv\Lib\site-packages\pandas\
Any ideas on what I should do?
EDIT:
I noticed that even though I created the notebook using the venv, it uses the normal python environment rather than the virtual one. Ideas on how to fix this?
Well I think I solved it. If ran the following command:
python -c "import IPython"
Which just installs IPython in my venv.
You need to restart the notebook kernel, it will probably work then.
In the future, in a notebook cell you can run
%%bash
pip install pandas
then you should be able to continue without restarting

Install python packages on Jupyter Notebook

I am trying to install 2 python packages on Anaconda Jupyter Notebook. The links to the python packages are as follow:
1) https://iapws.readthedocs.io/en/latest/modules.html
2) https://pythonhosted.org/thermopy/iapws.html#module-thermopy.iapws
But I am getting the following error on both installations. Can anyone tell me what is wrong?
Through Anaconda you should write this on your Jupyter notebook :
# Install a conda package in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} packagename
With a normal install of python you should write this on your Jupyter notebook :
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install packagename
By replacing packagename with the name of your package like numpy.
Cheers
Your Jupyter notebook server does not have access to internet. You operating system might have a firewall or limit internet access to third party applications, especially since this is a work laptop.
Regardless, it is easy to install components using pip. If you cannot access the internet from inside the notebook, try opening a Command Prompt as admin and simply type pip install iapws.

Changing paths to fix Mac OSX:` -bash: jupyter: command not found`?

This question has been covered previously on SO, but the recommended fixes didn't work.
I have installed Jupyter both with pip install jupyter --upgrade and macports port install py34-jupyter but I cannot access the command jupyter via the command line.
When executing pip install jupyter, the message is:
Requirement already satisfied: jupyter in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
This is also where pip is located. I have also tried
pip uninstall notebook
pip install notebook --upgrade
but this didn't work.
Inside /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages, I see:
jupyter-1.0.0-py3.4.egg-info
jupyter-1.0.0.dist-info
jupyter.py
jupyter_client
jupyter_client-4.4.0-py3.4.egg-info
jupyter_client-4.4.0.dist-info
jupyter_console
jupyter_console-5.0.0-py3.4.egg-info
jupyter_console-5.0.0.dist-info
jupyter_core
jupyter_core-4.2.0.dist-info
jupyter_core-4.2.1-py3.4.egg-info
I thought perhaps it was possible that the command jupyter does not have the correct path to the executable necessary, but this doesn't appear to be the case.
How can I have access to jupyter notebook?
If you are using python on mac, I would strongly recommend using a virtualenv and installing all your dependencies using that. Had issues with installing and using several libraries.
pip install virtualenv virtualenvwrapper
# Create a backup of your .bash_profile
cp ~/.bash_profile ~/.bash_profile-org
# Be careful with this command
printf '\n%s\n%s\n%s' '# virtualenv' 'export WORKON_HOME=~/virtualenvs' \
'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bash_profile
source ~/.bash_profile
mkdir -p $WORKON_HOME
mkvirtualenv your_virtual_env
This creates the virtual environment
deactivate
When you are out of virtual env, you can uninstall jupyter from your machine using pip uninstall jupyter
workon your_virtual_env
pip install jupyter

Categories

Resources