Jupyter Notebook kernel keeps dying - python

I downloaded Anaconda Navigator months ago and have been using it to launch Jupyter Notebooks. Recently, I was trying to import Graphviz to visualize a decision tree and had a ton of trouble getting the package to work. I tried following various command line instructions that I read on forums, but somewhere in following some of those instructions, I must have completely messed up my conda environment. I am no longer able to open Anaconda. I tried uninstalling it and reinstalling (followed the directions for uninstalling it from the Anaconda documentation page). Everytime I try to reinstall it, it says the installation has failed or that it already exists on my computer.
I gave up on Anaconda and went ahead installing Jupyter Notebooks on its own. This worked just fine and I'm able to launch a kernel, but every time I try to execute code, it says the kernel has died and will automatically restarted.
I have gone down many rabbit holes...any help would be greatly appreciated!

Related

Python isn't working at all. Jupyter Notebook can't connect to kernel and crashes, Spyder (via Anaconda) also crashes

Windows 11. I have an Anaconda installation of Python and use both Jupyter Notebook and Spyder occasionally. Everything was fine last week. Now suddenly, I have something similar happening to what's being described here: Jupyter Notebook - Cannot Connect to Kernel
But Spyder is also immediately crashing after opening. I tried conda update jupyter and conda update notebook, a substantial number of packages updated, but same problem. I also tried to revert tornado to 5.1.1 but that was incompatible with the current version of Python I have, 3.10.8.
I tried to search for some ill-named or placed Python scripts, but there really shouldn't be any, they're all in folders in the host Jupyter Notebook directory. And I don't really understand Python environments or want to keep track of them so I'd rather not attempt that (one of the answers of the previous post).
enter image description here

Jupyter Notebook and Anaconda Navigator don't open on Windows

I work with Jupyter Notebook through Anaconda on Windows 10, and I've never had any problems. However recently Anaconda Navigator 2020.5 started not opening and disappeared from my apps list. I tried uninstalling and reinstalling, I followed all the steps and the installation went perfectly and Anaconda Navigator opened again, but Jupyter Notebook doesn't open the browser. I updated Anaconda, restarted the app and then Anaconda Navigator stopped working again. I tried one more reinstall and the problem was repeated, and now I can't access Jupyter Notebook anymore and I'm afraid of losing all my codes. I have no idea what's going wrong, can someone help me for God's sake. I also got two versions of Python installed, which is Python 3.8 and 3.9

Importing library error: No module named <pkg>

In the past, I downloaded an open-source package through pip when I was just using it and it worked fine but I have recently started to help with the development of the package so I cloned the github repository onto my laptop and am now having troubles. I checked out and pulled the changes to a new branch in the github repository to work with some changes someone else made but my Jupyter Notebook was still using the old version of the package as I couldn't access the new methods in the notebook I was working in. If I open the code through 'open .' when in the directory, I can see that it is the proper code that I need to run but Jupyter notebook was not running that code. I then ran 'pip freeze' in my terminal and saw a package was still installed there so I ran 'sudo pip uninstall ' and uninstalled the package from pip. Although now, when I try to import the package into my Jupyter Notebook I get the error where there is:
No module named <package name>
Does anyone know why this is happening and how I can fix it? I would like to be able to use the version of the code of which branch I am in currently.
EDIT:
The package library is stored in /Users/myName/pkg. I am trying to access this through the 'import ' statement in Python. I am running this import statement through a Jupyter notebook in Jupyter lab. Jupyter lab is installed under python3.7/anaconda3/bin/jupyter-lab. I used to have another version of this open-source library installed which I installed using pip, but I recently uninstalled it as I thought that was causing the problem.
I also ran
sys.executable
and it returned '/anaconda3/bin/python'
EDIT 2:
I tried following the solution from this post but when I activated my new environment created, my entire jupyter lab local-host page just kept refreshing constantly and would not load anything. Although when I do not activate that environment I can run my old jupyter lab fine.
EDIT 3:
SOLUTION:
The solution I linked above worked for me, although I also had to update my Jupyter Lab in the new conda environment to stop my page from being infinitely refreshed.

Why does jupyter notebook server keeps crashing when .ipynb files are opened?

I was able to use jupyter notebook 4 days ago. The only thing that changed was there was a firefox version update.
After that the server crashes everytime .ipynb files are opened. Even the directory will have a server error. I tried it both on Firefox and Google Chrome, both browsers will crash the server.
My only kernel is python3 and it always says "Kernel Busy". I tried resetting my pc and the jupyter notebook, but nothing seems to work.
The console showed:
The last 2 lines are causing the crash but I don't know how to fix it
When I type conda install jupyter in the anaconda prompt, I get something before it finishes as shown below. Maybe it might have a cause as to why it is having issues:
I created a new python environment and installed python, matplotlib, pandas, jupyter and it still crashes
Please uninstall and re-install all the below items:
ipykernel
ipython
jupyter_client
jupyter_core
traitlets
ipython_genutils
Additionally, if you're going to install with conda, follow below command.
run conda clean -tipsy
This command will clean up conda caches before you start.
Reference:
https://github.com/jupyter/notebook/issues/1892
Do you let Jupyter start the browser? If so, disable that and start the browser manually. I don't see how the zmq error messages could be related to the browser startup, but since you say that the only change was a browser update, that's worth a shot.
Check which version of pyzmq is installed. If Jupyter Notebook and the kernel are in different conda envs, check both and make sure they are on the same version and build. Try upgrading or downgrading to different versions. According to Anaconda issue 8932, there are problems with pyzmq on Windows. And a new build for win32 was released about two weeks ago - though I would expect win64 builds to be used nowadays.
I also found some recommendations for a similar error message to yours in Spyder issue 6097. The first one is to try without firewall and/or antivirus. You might have picked up a new firewall rule unknowingly. Trying different versions of pyzmq is also mentioned there.
I am sharing this solution in case someone needs it in the future.
I have just faced the same problem a hour ago. This was the message I was getting in the terminal. And the jupyter keeps restarting.
ModuleNotFoundError: No module named 'html.entities'; 'html' is not a package
[I 00:44:32.436 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
After Searching through the internet when I can not find the solution. I fixed it by removing the .HTML files I had in the directory. After moving those file jupyter started working parfectly.
I just had a similar problem - for me, it was casued by a non-existing %temp% directory (I have %temp% mapped to a ram disk, and the temp folder on it wasn't created yet).
Creating the folder pointed to by %temp% solved the issue.
All my environments were working totally fine but suddenly after restarting the system, the jupyter notebook from an environment was not opening or it was suddenly crashing. Tried form anaconda prompt but getting "Unable to create Process...
All my DL dependencies were on this environment and I didn't want to create new environment completely installing all the required dependencies.
Solution: I opened the Anaconda Navigator and cloned old_env to new_env and it worked magically. I could able to open the jupyter notebook successfully and all dependencies were working fine. Hope it helps

Tensorflow: Trouble importing Tensorflow in a Jupyter Notebook

I have a conda environment with Tensorflow-gpu installed for python 3.6.6. I am running Ubuntu linux 16.04 LTS. When I activate the environment and start a python shell, I can import Tensorflow just fine. But when I start up a Jupyter notebook or Jupyter lab session, I can't import Tensorflow.
Now there is a pre-existing SE post on this issue. However, that post is 2 years old, so there are changes in Jupyter since then. Second, I tried the fixed mentioned in that post, and none of them have worked. So I was hoping there might be some progress or some new ways to fix this.
So let me provide a little more detail on the issue.
First, when I activated a python 3.6.6 environment in anaconda and did conda list in a regular Tilix terminal session, I can see that Tensorflow-gpu is listed.
When I start ipython in a standard Tilix terminal and type import tensorflow as tf, that works fine.
Next, I started a jupyter lab session and opened a terminal from the jupyter launcher. In the terminal I started an ipython session and tried to import tensorflow. That does not work.
I opened a new jupyter notebook and tried to import Tensorflow then I "ModuleNotFoundError: No module named 'tensorflow'" error.
If I just run a python file with tensorflow code from the regular tilix terminal, then it will run fine and find Tensorflow. So only the notebook seems to be the big problem.
Things that I have tried:
I did try to implement a few of the fixes suggested in the older SE post, as well as the closed github issue on this problem.
I tried to reinstall tensorflow
I did a conda install of ipython, jupyter because some folks suggested installing those into the environment directly.
I looked at the jupyter kernelspec list. Some folks suggested making a change to this, but it was not clear what to change.
I installed the conda install -c anaconda-nb-extensions nb_conda in the environment too, but still no luck.
Anyone else have a suggestion about how to fix this.

Categories