Unable to launch jupyter notebook supposedly due to jsonschema - python

I started facing this error after installing keras via - conda install -c conda-forge keras.
Now when I try to launch Jupiter notebook I am prompted with the following:
Traceback (most recent call last):
File "C:\Users\srish\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 31, in <module>
from importlib import metadata
ImportError: cannot import name 'metadata' from 'importlib' (C:\Users\srish\Anaconda3\lib\importlib\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\validator.py", line 12, in <module>
from jsonschema import ValidationError
File "C:\Users\srish\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 33, in <module>
import importlib_metadata as metadata
ModuleNotFoundError: No module named 'importlib_metadata'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\srish\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\srish\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 80, in <module>
from .services.contents.manager import ContentsManager
File "C:\Users\srish\Anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "C:\Users\srish\Anaconda3\lib\site-packages\nbformat\validator.py", line 23, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: No module named 'importlib_metadata'
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
The solution of the following link seems to be outdated, and is for python 2.7 only: Can't use Jupyter Notebook: jsonschema apparently missing.

Your Solution Worked for me. I had originally upgraded to jsonschema 3.20. I then downgraded to version jsonschema 3.02 and now my Jupyter notebook opens. Don't know why the higher version 3.20 creates the problem.

Well I also felt the same problem and my notebook or lab was also not opening. I found an answer in an website. I used the command conda install jsonschema==3.0.2 in the Anaconda Prompt and after installing my notebook and lab works fine again.

If you don't mind what version of anaconda you're using, downgrading anaconda to the 2020.02 version solved it for me (using conda install anaconda=2020.02).
This happend to me when I updated anaconda to the 2020.07 version using conda install anaconda=2020.07. I tried conda install jsonschema==3.0.2 as #user14080268 mentioned, but this caused the solving environment to fail and it went to look for incompatible packages, which then took for ever. Downgrading anaconda back to the version I initially had fixed the issue for me!
(of course, if you had a specific reason to update anaconda this might not be the best solution for you)

Related

jupyter notebook showing this message, ImportError: cannot import name 'encodestring' from 'base64'

I am new to python and jupyter notebook and I am using windows. Recently I installed Anaconda Navigator 2.3.1 and the python verson 3.9.13 on my computer. After entering the command jupyter notebook on the command-line, my browser doesn't open jupyter notebook, instead that showing me this error message:
(base) C:\Users\USER>jupyter notebook
Traceback (most recent call last):
File "D:\Anaconda3\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "D:\Anaconda3\anaconda3\lib\site-packages\notebook\notebookapp.py", line 79, in <module>
from .services.contents.manager import ContentsManager
File "D:\Anaconda3\anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\__init__.py", line 14, in <module>
from . import v1
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\v1\__init__.py", line 19, in <module>
from .nbjson import reads as reads_json, writes as writes_json
File "C:\Users\USER\AppData\Roaming\Python\Python39\site-packages\nbformat\v1\nbjson.py", line 19, in <module>
from base64 import encodestring
ImportError: cannot import name 'encodestring' from 'base64' (D:\Anaconda3\anaconda3\lib\base64.py)
I don't understand what should do now? And how to solve this issue! Please help..........
base64.encodestring was deprecated since python 3.1 and finally removed in 3.9
You can compare the official documentation for the base64 library for version 3.8 and 3.9
https://docs.python.org/3.8/library/base64.html
https://docs.python.org/3.9/library/base64.html
I'm not sure exactly how you installed anaconda navigator but i would suggest using the latest distribution of anaconda which includes navigator
This error is caused by nbformat. Check your nbformat with the command 'pip freeze', and look for the nbformat version. Most likely your version is anterior to 5.1.3.
Upgrade to that version with the following command:
pip3 install nbformat==5.1.3
or just 'pip install nbformat==5.1.3' ; depending on your configuration.
It should fix the issue.
Francis Massolin
Services that grow your business!

Python Anaconda ImportError: menuinst.knownfolders

I am trying to work with my Jupyter notebook. I have done so for the last 6 six years or so. Now I am getting the following error message:
Python Anaconda ImportError No module named menuinst.knownfolders
I checked several posts on the internet but nothing has helped: “conda install menuinst”. see here:
Python Anaconda ImportError No module named menuinst.knownfolders
I now have uninstalled and re-installed it three times but did not solve the issue.
When I go to my anaconda prompt and type in “jupyter notebook”, these are the error message I am getting:
C:\Users\User\anaconda3\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
_cffi_ext.c
AppData\Roaming\Python\Python38\site-packages\zmq\backend\cffi\__pycache__\_cffi_ext.c(268): fatal error C1083:
Cannot open include file: 'zmq.h': No such file or directory
Traceback (most recent call last):
File "C:\Users\User\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\User\anaconda3\lib\site-packages\notebook\notebookapp.py", line 49, in <module>
from zmq.eventloop import ioloop
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\__init__.py", line 50, in <module>
from zmq import backend
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: cannot import name 'constants' from partially initialized module 'zmq.backend.cython' (most likely due to a circular import) (C:\Users\User\AppData\Roaming\Python\Python38\site-packages\zmq\backend\cython\__init__.py)
Just another piece of information, my anaconda prompt starts with (base) before it says C:\user\user>. Is that relevant or this issue?
You should try
conda remove zeromq
conda install zeromq
Solution-1
Please try to reinstall jupyter notebook from anaconda navigator it will definitely work
Solution-2
Please update jupyter notebook from anaconda prompt with below commands.
pip install notebook --upgrade
conda update notebook
I face the same issue..
1)Open anaconda prompt and type
conda list
2)Check terminado and
terminado 0.8.3
zeromq 4.3.2
3)In same anaconda prompt and check if python is working, type below code
python
if yes then
quit()
5)if no update python accordingly.
6)Type,
anaconda-navigator
This will open navigator and try to install jupyter notebook.

Jupyter suddenly won't start without (already-installed) packages

I was having issues installing a package. I cancelled the install mid-solving environment.
Now, when I try to open Jupyter notebook, I receive the following error:
Traceback (most recent call last):
File "/Users/Me/opt/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 80, in <module>
from .services.contents.manager import ContentsManager
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/notebook/services/contents/manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/nbformat/__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "/Users/Me/opt/anaconda3/lib/python3.7/site-packages/nbformat/validator.py", line 23, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: No module named 'importlib_metadata'
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
I tried installing jsonschema and importlib_metadata via conda install. When I do that, I receive this (for both):
# All requested packages already installed.
I tried turning it off and on again; I tried removing and reinstalling Jupyter. Neither worked. This is abhorrently frustrating. What the heck is going on, and why is Jupyter suddenly deciding to not work when it worked perfectly before the weekend? And more importantly, how do I fix this?

IPython suddenly broken in conda environment: cannot import uniq_stable

I'm doing work in a conda environment. Today when I entered the environment, IPython failed to run, with the following error:
Traceback (most recent call last):
File "/home/d04/jayat/miniconda3/envs/umiopy/bin/ipython", line 4, in <module>
import IPython
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/home/d04/jayat/miniconda3/envs/umiopy/lib/python2.7/site-packages/IPython/core/ultratb.py", line 127, in <module>
from IPython.utils.data import uniq_stable
ImportError: cannot import name uniq_stable
IPython is up to date:
ipython 5.3.0 py27_0
It seems to be searching in the right place:
$ which ipython
~/miniconda3/envs/umiopy/bin/ipython
I'm using conda 4.3.14.
I've not changed anything in the environment but it's possible something has been updated by the system administrators (though it's hard to understand how that could affect my environment). What could be causing this problem? For similar errors on StackOverflow it seems like I'll need to update some module through conda.
If anyone ever experiences this issue, after some period of time, reinstalling iPython resulted in it working. I have no idea what broke it in the first place, and why reinstalling didn't help previously. Some sort of conda-related problem I suppose.
It's this simple:
conda remove ipython
conda install ipython

Can no Longer open Spyder IDE for Python Programming

I installed Python 3.4 on my Windows 7 laptop several months ago as part of Anaconda (https://www.continuum.io/downloads). My installation included the Spyder IDE, and I have successfully been using Spyder for Python programming.
However, since yesterday, I have been unable to open Spyder. I typically open Spyder via the Start Menu, but now, when I try to click on the Spyder icon in the Start Menu, I get no response. I then tried to go directly to the spyder.exe file in the Scripts folder in the directory where Anaconda is installed. When I clicked on this the first time, the following message flashed quickly and then disappeared:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 114, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
I double-clicked on Spyder.exe a second time, and this time, received the following message:
kfile.py", line 146 in lock
symlinke(str(os.getpid()), self.name)
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\utils\external\lockfile.py", line 87, in symlink
os.rmdir(newlinkname)
OSError: [WinError 145] The directory is not empty: 'C:\\Users\\Aniket\\.spyder2-py3\\spyder.lock.1459432906109.newlink'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aniket\Anaconda3\Scripts\spyder-script.py". line 2, in <module>
start_app.main()
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\start_app.py", line 106, in main
from spyderlib import spyder
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 100 in <module>
File "C:\Users\Aniket\Anaconda3\lib\site-packages\spyderlib\qt\QtSvg.py", line 10 in <module>
from PyQt4.QtSvg import * # analysis:ignore
ImportError:DLL load failed: The specified module could not be found
Both of these messages flashed very quickly and then disappeared - I captured them by quickly pressing Print Screen when they appeared. It's not evident to me what the error messages imply, nor what would have caused this. It's possible that I closed Spyder while some function was running, or that Spyder crashed and caused some persistent error. Does anyone know how I can fix this?
I had a similar problem of Spyder 2 not starting. My installation is part of Anaconda, on Win7 64-bit OS. I tried all the solutions outlined here and here, but they did not work for me. From the command line, I got the following error(s) when trying to reset spyder:
U:\>python -c "from spyderlib.spyder import main; main()" --reset
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 48, in <module> from PySide import __version__ # analysis:ignore
ImportError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 40, in check_qt from spyderlib import qt File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\qt\__init__.py", line 50, in <module>
raise ImportError("Spyder requires PySide or PyQt to be installed")
ImportError: Spyder requires PySide or PyQt to be installed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\spyder.py", line 48, in <module> requirements.check_qt()
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 50, in check_qt % (qt_infos['pyqt']+qt_infos['pyside']))
File "C:\Temp\pApps\Anaconda3\lib\site-packages\spyderlib\requirements.py", line 25, in show_warning
raise RuntimeError(message)
RuntimeError: Please check Spyder installation requirements:
PyQt4 4.6+ (or PySide 1.2.0+) is required.
What surprised me was that spyder worked fine till yesterday, and I just did a full update yesterday as follows:
conda update --all
So I again updated spyder today with the following:
conda update spyder
And the following package plan was presented to me:
The following packages will be UPDATED:
spyder: 2.3.7-py35_3 None://None/<unknown> --> 2.3.8-py35_1
spyder-app: 2.3.7-py35_0 --> 2.3.8-py35_0
The following packages will be DOWNGRADED due to dependency conflicts:
matplotlib: 1.5.3-np111py35_1 --> 1.5.1-np111py35_0
pyqt: 5.6.0-py35_0 --> 4.11.4-py35_7
qt: 5.6.0-vc14_0 [vc14] --> 4.8.7-vc14_9
[vc14]
qtconsole: 4.2.1-py35_2 --> 4.2.1-py35_0
After the update, spyder works fine now.
In essence, my problem was due to dependency conflicts.
I ran into the same issue. The following worked for me
Please close Spyder IDE, in Anaconda Prompt run
conda update spyder
then
spyder --reset
Restart Spyder
Had the same exact problem as you a few days ago and reinstalling won't work so I went to:
C:\Users\'YourName'\\.spyder2-py3
delete every spyder, lock file/folder in it and relaunch.
I know this is an old thread but having just had the same problem an answer that worked for me from https://github.com/spyder-ide/spyder/issues/3005
My problem appeared to be that the status of spyder was still running so wouldn't open. To fix this you need to look for a directory called .spyder2 in your Users\ directory, then find a file called spyder.lock and remove it.
My solution:
I uninstalled Anaconda spyder
Removed all directories of it from
c: programs/
and c:users/Username/
and c:users/username/AppData/local
and c:users/username/AppData/
I downloaded a newer version of Anaconda Spyder and installed it.
It's all fine now.
You might get additional information if you run
from spyder.app import start
start.main()
as a python script. For example I got following output:
Traceback (most recent call last):
File "C:\python_env\workspace\TechDiff\src\demo.py", line 1, in <module>
from spyder.app import start
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\app\start.py", line 24, in <module>
from spyder.config.base import get_conf_path, running_in_mac_app
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\config\base.py", line 25, in <module>
from spyder.utils import encoding
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\utils\encoding.py", line 23, in <module>
from spyder.py3compat import (is_string, to_text_string, is_binary_string,
File "C:\python_env\App\WinPython\python-3.10.1.amd64\lib\site-packages\spyder\py3compat.py", line 77, in <module>
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (C:\python_env\App\WinPython\python-3.10.1.amd64\lib\collections\__init__.py)
=> Maybe for Python 3.10 the import of collections needs to be fixed.
=> Try to use 3.9
I've got exactly the same error messages before, and I fixed it by installing spyder again under anaconda:
conda install spyder
Well it says it is missing PyQt4.dll, which you can check by: searching pyqt4 in your anaconda3 directory.
There are several possibilities:
it is still in: ~\Anaconda3_x86\Library\plugins\designer
That would mean python can't find since it ain't searching in this directory, I highly doubt that possiblity, since that would mean you'd have tweaked some code.
it ain't anywhere
Maybe you or more likely one of your programs did deleted it per accident?
it isnt in: ~\Anaconda3_x86\Library\plugins\designer
I also doubt this possibilty since it would mean the file has been moved...
However you can fix that by reinstalling spyder as mentioned by xuwei.

Categories

Resources