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

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.

Related

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

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

Graphite synthesize install quits with error - Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-7a0tqlu_/cryptography/ [duplicate]

I am trying to install pyOpenSSl and it shows the following error
Requirement already satisfied: six>=1.5.2 in /home/tony/hx-preinstaller-venv/lib/python3.6/site-packages (from pyOpenSSL)
Collecting cryptography>=3.3 (from pyOpenSSL)
Using cached https://files.pythonhosted.org/packages/cc/98/8a258ab4787e6f835d350639792527d2eb7946ff9fc0caca9c3f4cf5dcfe/cryptography-3.4.8.tar.gz
Complete output from command python setup.py egg_info:
=============================DEBUG ASSISTANCE==========================
If you are seeing an error here please try the following to
successfully install cryptography:
Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
=============================DEBUG ASSISTANCE==========================
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-8toyhikv/cryptography/setup.py", line 14, in <module>
from setuptools_rust import RustExtension
ModuleNotFoundError: No module named 'setuptools_rust'
the command i ran
pip install pyOpenSSL
Thanks in advance
Try upgrade pip and install setuptools-rust:
pip install --upgrade pip
pip install setuptools-rust
Have you tried upgrading pip itself first?
pip install --upgrade pip
I had same issue while using 'scrapy' and following command fixed everything for me:
python3 -m pip install scrapy --upgrade --force --user
Try installing setuptools_rust first:
pip install setuptools_rust
And then installing pyOpenSSL again
Use this command if you are on linux
for python3
python3 -m pip install --upgrade pip
for python2
python2 -m pip install --upgrade pip
this worked for me.
Upgrading the pip this way worked for me:
python -m pip install --upgrade pip

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.

Reconnect minion on a new salt-master causes issues

I'm trying to reconnect minions to my new salt-master.
To do that,
I changed the sources.list
installing the new version of salt-minion (from 2015 to 2017.7.8)
Disconnect the minion from the old salt-master (I had two master to manage the old server because the internal application wasn't
uptodate to run a 2017 version of salt, and one for the uptodate
infrastructure)
I ran rm -r /etc/salt/pki
systemctl force-reload salt-minion.servce
I accepted the key on my new master
I ran salt-call state.sls motd (or whatever the formula)
The point is the following. For few of my minions, I cannot say why, but when I ran the last command salt-call state.sls motd I get this issue:
[ERROR ] An un-handled exception was caught by salt's global exception handler:
KeyError: 'saltutil.is_running'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 396, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 1071, in sls
conflict = running(concurrent)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 209, in running
active = __salt__['saltutil.is_running']('state.*')
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1121, in __getitem__
func = super(LazyLoader, self).__getitem__(item)
File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 101, in __getitem__
raise KeyError(key)
KeyError: 'saltutil.is_running'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 396, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 1071, in sls
conflict = running(concurrent)
File "/usr/lib/python2.7/dist-packages/salt/modules/state.py", line 209, in running
active = __salt__['saltutil.is_running']('state.*')
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1121, in __getitem__
func = super(LazyLoader, self).__getitem__(item)
File "/usr/lib/python2.7/dist-packages/salt/utils/lazy.py", line 101, in __getitem__
raise KeyError(key)
KeyError: 'saltutil.is_running'
My salt version:
Salt Version:
Salt: 2017.7.8
Dependency Versions:
cffi: 0.8.6
cherrypy: Not Installed
dateutil: 2.2
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.3
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.21.1
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: 1.2.3
pycparser: 2.10
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.4.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: debian 8.8
locale: UTF-8
machine: x86_64
release: 3.16.0-4-amd64
system: Linux
version: debian 8.8
I tried to uninstall salt-minion with:
apt-get autoremove salt-minion* -y
apt-get purge salt-minion* -y
aptitude purge salt-minion -y
And apt-get update & install salt-minion
But I still have the exact same error. And not on every minions. For some of them, I have the exact same configuration on each server, and it can work for one and not the other.
Any clue? Help :s

App Deployment: Django not installing on server- AttributeError: 'module' object has no attribute 'lru_cache'

I am trying to deploy a Django App and for some reason, I keep getting this error. It seems to me that Django is not installed but it also errors when installing. Thank you for the help on this. I am deploying on Amazon EC2
(venv) ubuntu#ip----:~/quotes$ pip install Django
Collecting Django
Using cached Django-2.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-build-ceP6se/Django/setup.py", line 32, in
version = __import__('django').get_version()
File "django/__init__.py", line 1, in
from django.utils.version import get_version
File "django/utils/version.py", line 61, in
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ceP6se/Django/
Django has stopped its support for Python 2 version, still you can try installing 1.11 version by using the below code.
pip install Django==1.11
According to the django 2.0 release notes, The Django 1.11.x series is the last to support Python 2.7 (Check it here)
So you can choose to use an older version of Django and then install it with this command:
pip install 'Django<2'
but if you decided to buildup your project using Django>=2.0 then you should create a virtual environment with python 3.4 or higher this way:
sudo apt-get update
sudo apt-get install python3 python3-pip
sudo -H pip3 install virtualenv
mkdir ~/myproject
cd ~/myproject
virtualenv -p `which python3` myprojectenv
source ~/myproject/myprojectenv/bin/activate
python -V
it should output something like this:
Python 3.X.Y
Now you are able to install the latest version of Django without any error:
pip install Django
Good luck,

Resources