Jupyter kernel keeps crashing -- "No module named prompt_toolkit.formatted_text" - python-3.x

I cannot get Jupyter Notebook running -- it keeps restarting the kernel and giving the error message,
ImportError: No module named 'prompt_toolkit.formatted_text'
A few threads online say it is an issue with ipython versioning which can be fixed by a rollback, but that hasn't worked for me.
Here are my current versions of relevant packages:
conda==4.5.11
ipykernel==4.10.0
ipython==6.5.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==4.1.1
jupyter-core==4.4.0
jupyter-kernel-gateway==2.1.0
jupyterlab==0.34.12
jupyterlab-launcher==0.13.1
notebook==5.7.0
prompt-toolkit==1.0.15
Any help you can provide would be great. Thanks!

I did have the same issue with Jupyter Notebook. Point is that ipython requirement specific version of prompt-toolkit. In my case, I have ipython 7.2.0 which required prompt-toolkit <2.1.0,>=2.0.0
I just added prompt-toolkit<2.1.0,>=2.0.0 to my requirements.txt to solve this problem.
Try to run pip install prompt_toolkit and see which version of prompt_toolkit need in your project.

Related

Cannot import torch Error loading ..\caffe2_nvrtc.dll" or one of its dependencies

I am on a Windows 10 64 bit system.
Pytorch for cuda has been working successfully for some time.
Today I tried to upgrade to the latest version of Pytorch (1.13) using
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
Now I cannot import torch. I get the error:
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\alan\anaconda3\lib\site-packages\torch\lib\caffe2_nvrtc.dll" or one of its dependencies.
I have tried both in a Jupyter notebook and in the Spyder IDE.
I have tried completely removing Anaconda and reinstalling afresh and then reinstalling Pytorch with no success.
I do not believe I have any other versions of python installed.
The offending dll (caffe2_nvrtc.dll) does seem to be in the file location specified.
I have found various similar problems reported but they all date back to 2020 or earlier and none of them seemed to have a satisfactory solution.
Can anyone point me in the correct direction
I still do not understand why using conda did not work but I tried again using pip
and that did work
I experienced the same problem as yours today.
It turns out that when I use the anaconda prompt then the problem disappears.
Anaconda prompt could do it
Then I speculated that the only difference between these two scenarios is that when I use the anaconda prompt, I use the base anaconda environment, probably somehow the conda environment in spyder is not activated.
So the solution is to open the spyder in anaconda prompt like this:
Then it works.
This picture will tell you the cause for the problem.
problem...

ShimWarning on running `help("modules")`

When running help("modules") in python 3.8 (both inside of Jupyter Notebook and in regular python terminal), the following warning appears:
/opt/conda/lib/python3.8/site-packages/IPython/kernel/__init__.py:12:
ShimWarning: The `IPython.kernel` package has been deprecated since IPython 4.0.
You should import from ipykernel or jupyter_client instead.
warn("The `IPython.kernel` package has been deprecated since IPython 4.0.")
Is there some package or library I need to update in order to resolve this warning? What does it mean to import from ipykernel or jupyter_client?
I noticed in the replies to another thread that someone else has run into this exact issue, but no answers. Thanks in advance!

Huggingface Transformers ByteLevelBPETokenizer tokenizer not found

I'm trying to run through the (new) tutorial here: https://huggingface.co/blog/how-to-train, but hit an error trying to load the ByteLevelBPETokenizer. I started from an existing conda env and also tried with a totally fresh env, but both give the same error:
Exception has occurred: ImportError
cannot import name 'ByteLevelBPETokenizer' from 'tokenizers' (/home/james/anaconda3/envs/torch/lib/python3.7/site-packages/tokenizers/__init__.py)
Any thoughts as to what might be wrong?
I'm on Ubuntu 18.04, Python 3.7
Okay, turns out the transformers installer pulls an older version (0.0.11). So...
pip uninstall tokenizers
pip install tokenizers==0.4.2
...fixes it.
It does issues a warning: ERROR: transformers 2.4.1 has requirement tokenizers==0.0.11, but you'll have tokenizers 0.4.2 which is incompatible., but this can safely be ignored (this answer came from #julien-c at huggingface/tokenizers).

IPython Notebook showing `ImportError`

I am using Ubuntu 15.04 and I just installed IPython 4.0.
Now, when I type ipython notebook in the terminal, I get the following error message:
ImportError: No module named notebook.notebookapp
I have read related questions on this site but I could not solve this situation.
Since, I have no working knowledge of IPython,so I could really use some advice to fix this.
Try pip install "ipython[notebook]"
and take a look here:
http://ipython.org/install.html#i-already-have-python.
This should install all the dependencies and get you up and running.

Anaconda3 libhdf5.so.9: cannot open shared object file [works fine on py2.7 but not on py3.4]

I just tried to use pd.HDFStore in IPython Notebook with a Python 3 kernel (Anaconda 2&3 on Ubuntu 14.04)
import pandas as pd
store = pd.HDFStore('/home/Jian/Downloads/test.h5')
but it throws the following error
ImportError: HDFStore requires PyTables, "libhdf5.so.9: cannot open shared object file: No such file or directory" problem importing
I initially thought it's because pytables is somehow missing, but when I check $source activate py34 and $conda list, pytables 3.2.0 is already installed under anaconda python3 environment.
Also, if I switch to Python 2, for example, $source activate py27 and start ipython notebook, it works properly and no import error is thrown.
I guess that I must miss something for configuring pytables under anaconda python 3 env, but I cannot figure it out. Any help is highly appreciated.
Update:
I just tried on a fresh install of Anaconda3-2.3.0-Linux-x86_64 from official website and it ends up with the same error. When I try $locate libhdf5.so.9 in command line, nothing shows up.
This is a known issue that we are working on. When it is fixed, conda update --all will update the libraries and fix the issue.

Resources