Problem to open Jupyter notebook: cannot import name 'escape' from 'markupsafe' - jupyter-notebook

Have you guys faced this problem before? I was installing cuCNN and after the installation, I cannot open Jupyter Notebooks anymore.
When I try it I got this error:
(base) PS C:\Users\USER> jupyter notebook
(base) PS C:\Users\USER> jupyter notebook
Traceback (most recent call last):
File "D:\Program Files(D)\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "D:\Program Files(D)\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 43, in <module>
from jinja2 import Environment, FileSystemLoader
File "D:\Program Files(D)\Anaconda3\lib\site-packages\jinja2\__init__.py", line 6, in <module>
from markupsafe import escape
ImportError: cannot import name 'escape' from 'markupsafe' (unknown location)
(base) PS C:\Users\USER>
Does anyone know how to solve it?
I executed these commands to install cuDNN:
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/
python3 -m pip install tensorflow
https://www.tensorflow.org/install/pip#windows-wsl2

I solved it hopefully:
"You have to reinstall markupsafe"
After trying several things I had to remove "markupsafe" manually, because "pip uninstall markupsafe" did not work out, once removed it, proceed to install markupsafe again(pip install markupsafe)... and that's it.
Note that for me only worked markupsafe 2.0.1, superior versions had other problems(this problem: https://github.com/aws/aws-sam-cli/issues/3661)
pip install markupsafe==2.0.1

Related

How can I open jupyter notebook in venv to my drake work correct

I install drake via pip in venv and I want open files from course underactuated.
I start venv by typing:
source env/bin/activate
Drake installed correct because of output of python3 -c 'import pydrake.all; print(pydrake.__file__)':
(env) dmitriy#dmitriy:~/git/underactuated$ python3 -c 'import pydrake.all; print(pydrake.__file__)'
/home/dmitriy/env/lib/python3.8/site-packages/pydrake/__init__.py
But when I try run it in Jupyter notebook with Kernel env I have:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import pydrake.all; print(pydrake.__file__)
ModuleNotFoundError: No module named 'pydrake'
How can I open jupyter notebook in venv to my drake work correct ?
This is because I have not installed jupyter / IPython in your virtualenv.
This is the solution: Running Jupyter notebook in a virtualenv: installed sklearn module not available

How to enable Stata kernel in jupyter notebook

I am using MacOS and try to use Stata in the jupyter notebook. I went over the following step to do so.
First, in the terminal:
pip install stata_kernel
python -m stata_kernel.install
conda install -c conda-forge nodejs -y
jupyter labextension install jupyterlab-stata-highlight
pip install ipystata
And then in my jupyter notebook:
import ipystata
from ipystata.config import config_stata
config_stata('/Macintosh HD⁩/Applications/Stata/StataSE')
import ipystata
%%stata
display "Hello, I am printed in Stata."
But I keep getting the error message
UsageError: Line magic function %%stata not found.
I am not sure if this is path problem or something else.
Could you help me to fix the problem?

in Jupyter Notebook ModuleNotFoundError: No module named 'plotly'

I installed plotly library using anaconda prompt and it is appearing in my conda list. I can use it in Spyder but when i Import it in my Jupyter Notebook it Shows an Import error.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-182e2a6c8e92> in <module>
----> 1 import plotly as py
ModuleNotFoundError: No module named 'plotly'
But in my conda list it is seen as this.
plotly 3.10.0 py_0 conda-forge
Your Jupyter Notebook is probably not part of the Anaconda. Hence it is not recognising packages installed through Anaconda.
Solution 1
install Jupyter Notebook in Anaconda and try to run notebooks from there. When you will import plotly there it will be imported.
Solution 2
install pip. Here's how: how to install pip
Then use pip install plotly in command prompt.
You will be able to import plotly in Jupyter now.
Feel free to comment if you have any questions.

Upgrading from IPython 5.x to 6.0 results in crash due to IPython.utils.warn

I recently upgraded from IPython 5.x to 6.0 via condo update ipython. However, I get a crash in the kernel:
Traceback (most recent call last):
File "//anaconda/lib/python3.5/runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "//anaconda/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "//anaconda/lib/python3.5/site-packages/ipykernel/__main__.py", line 2, in <module>
from ipykernel import kernelapp as app
File "//anaconda/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 37, in <module>
from .ipkernel import IPythonKernel
File "//anaconda/lib/python3.5/site-packages/ipykernel/ipkernel.py", line 15, in <module>
from .zmqshell import ZMQInteractiveShell
File "//anaconda/lib/python3.5/site-packages/ipykernel/zmqshell.py", line 46, in <module>
from IPython.utils.warn import error
ImportError: No module named 'IPython.utils.warn'
[I 18:35:28.928 NotebookApp] KernelRestarter: restarting kernel (1/5)
Apparently, the issue is that IPython.utils.warn was deprecated and has now been removed as of version 6.0.0. How can I fix this?
Note: none of the following worked:
pip install --upgrade ipython
pip install --upgrade jupyter
pip install --upgrade --no-deps --force-reinstall ipython
pip install --upgrade --no-deps --force-reinstall jupyter
I had the same issue. The following line fixed the issue for me:
conda update ipykernel
I don't know why this is not done automatically.
+1 same problem.
Workaround was to downgrade to the latest available 5.x version of iPython (currently 5.3.0 found via conda search ipython):
conda install ipython=5.3.0
Now Jupyter notebook kernel can start again.

Jupyter: jupyter-notebook can not import module statsmodels

I have installed jupyter notebook in MacOS 10.9 Mavericks, using command
pip3 install jupyter
I can import some libraries like numpy, pandas and run Jupiter notebook normally, however, if I import the module statsmodels, it says No Module named "statsmodels'.
How can we run the installed library statsmodels in jupyter-notebook?
I had the same problem.
That's because the module has been install for python2 and not for python3 that you are using as well.
Find your python3 bin related to jupyter.
$jupyter --paths
Mine was at /usr/local/Cellar/python3/3.5.2_3/bin
run :
$python3 -mpip install statsmodels
cheers

Resources