When I use the command jupyter notebook I get the following error and traceback:
Error in sitecustomize; set PYTHONVERBOSE for traceback:
KeyError: 'PYTHONPATH'
Error in sitecustomize; set PYTHONVERBOSE for traceback:
KeyError: 'PYTHONPATH'
Traceback (most recent call last):
File "/Users/hamedbh/anaconda3/bin/jupyter-notebook", line 4, in <module>
import notebook.notebookapp
File "/usr/local/lib/python2.7/site-packages/notebook/notebookapp.py", line 31, in <module>
from zmq.eventloop import ioloop
File "/usr/local/lib/python2.7/site-packages/zmq/__init__.py", line 34, in <module>
from zmq import backend
File "/usr/local/lib/python2.7/site-packages/zmq/backend/__init__.py", line 40, in <module>
reraise(*exc_info)
File "/usr/local/lib/python2.7/site-packages/zmq/utils/sixcerpt.py", line 34, in reraise
raise value
File "/usr/local/lib/python2.7/site-packages/zmq/backend/__init__.py", line 27, in <module>
_ns = select_backend(first)
File "/usr/local/lib/python2.7/site-packages/zmq/backend/select.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
ModuleNotFoundError: No module named 'zmq.backend.cython'
I am using the full Anaconda distribution, and although I have created an environment I did this from the root Anaconda env (i.e. /Users/me/anaconda3) and not within an env.
Some quick details that may help with figuring out the problem:
python --version = Python 3.6.1 :: Anaconda 4.4.0 (x86_64)
OS is MacOS Sierra 10.12.6
I don't know whether the same thing that is causing the KeyError: PYTHONPATH is also causing jupyter notebook to fail.
It seems that pyzmq is the problem. Run pip install pyzmq --upgrade or pip unistall pyzmq & pip install pyzmq to make sure you're on the latest version of it.
Related
A while back, I upgraded my python version via brew to 3.9.0 and now, whenever I try to start Jupiter notebook, I get this error:
Traceback (most recent call last):
File "/Users/me/Library/Python/3.9/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/Users/me/Library/Python/3.9/lib/python/site-packages/notebook/notebookapp.py", line 49, in <module>
from zmq.eventloop import ioloop
File "/usr/local/lib/python3.9/site-packages/zmq/__init__.py", line 62, in <module>
from zmq import backend
File "/usr/local/lib/python3.9/site-packages/zmq/backend/__init__.py", line 32, in <module>
raise original_error from None
File "/usr/local/lib/python3.9/site-packages/zmq/backend/__init__.py", line 27, in <module>
_ns = select_backend(first)
File "/usr/local/lib/python3.9/site-packages/zmq/backend/select.py", line 32, in select_backend
mod = import_module(name)
File "/usr/local/Cellar/python#3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.9/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
from . import (
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/zmq/backend/cython/constants.cpython-39-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /usr/local/lib/python3.9/site-packages/zmq/backend/cython/../../.dylibs/libsodium.23.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/lib/python3.9/site-packages/zmq/backend/cython/../../.dylibs/libsodium.23.dylib
I've tried completely uninstalling and reinstalling jupiter to no avail. I've also tried reinstalling the zmq module that seems to be a part of this error chain. My thought is that there must be some component that's avoiding my uninstalls that needs to be fixed/updated, but I'm not sure what it could be.
I'm also running MacOS 10.13.6. I notice it states that one of these modules was built for Mac OS X 10.15. Could this instead be the issue?
The answer provided in this link worked for me:
Cannot run jupyter everywhere (terminal, anaconda distributer) Mac os 10.12.6
"downgraded pyzmq to 20.0.0 and it worked fine. pip install pyzmq==20.0.0
I believe the issue is in pyzmq's cython packaging - and should be raised as a bug to them."
The bug has been raised and is expected to be fixed by release 21.0.2
I have created a new virtualenv and named it python with command virtualenv python.
output:
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/dema/python/bin/python3.7
Also creating executable in /Users/dema/python/bin/python
Installing setuptools, pip, wheel...
done.
Then I activate it with commande source python/bin/activate
Then I installed jupyter notebook with commande pip3 install notebook
Then I try running the notebook with command jupyter notebook
The error:
Traceback (most recent call last):
File "/anaconda2/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/anaconda2/lib/python2.7/site-packages/notebook/notebookapp.py", line 60, in <module>
from tornado import httpserver
File "/anaconda2/lib/python2.7/site-packages/tornado/httpserver.py", line 33, in <module>
from tornado.http1connection import HTTP1ServerConnection, HTTP1ConnectionParameters
File "/anaconda2/lib/python2.7/site-packages/tornado/http1connection.py", line 30, in <module>
from tornado import iostream
File "/anaconda2/lib/python2.7/site-packages/tornado/iostream.py", line 40, in <module>
from tornado.netutil import ssl_wrap_socket, _client_ssl_defaults, _server_ssl_defaults
File "/anaconda2/lib/python2.7/site-packages/tornado/netutil.py", line 44, in <module>
_client_ssl_defaults = ssl.create_default_context(
AttributeError: 'module' object has no attribute 'create_default_context'
Why do Anaconda and python2.7 come into this when I am using an active env with python3.7? I am totally unable to understand.
Originally, Jupyter notebook was running well without any problems.
But after installing tensorflow and keras today, it doesn't work.
Error message:
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 85, in <module>
from .services.contents.manager import ContentsManager
File "C:\Anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\validator.py", line 12, in <module>
from .json_compat import get_current_validator, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\json_compat.py", line 10, in <module>
import jsonschema
File "C:\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 34, in <module>
__version__ = metadata.version("jsonschema")
AttributeError: module 'importlib_metadata' has no attribute 'version'
There is a problem with your importlib_metadata package, you can try uninstall it first and then forcing out a new installation with the following commands:
pip uninstall importlib_metadata
pip install importlib_metadata --force-reinstall
It worked for me.
This is a problem with the Anaconda version upgrade.
You can solve this with the following command that worked for me.
conda install -c conda-forge importlib_metadata
For me, the same error happened after VSCode proposed me to install a tensorboard plugin and I pressed yes. (MacOS 11.4, Conda 4.10.3)
It appears that it introduced some kind of version mismatch for multiple packages in the environment.
The following fixed the problem:
conda update --all
An import error occurs when trying to run jupyter notebook
I'm trying to run jupyter notebook using anaconda (git bash platform), and as I type in jupyter notebook, an import error occurs every time. I tried to lauch it inside an environment, but the same error occured.
$ jupyter notebook
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 47, in <module>
from zmq.eventloop import ioloop
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\select.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\User\Anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
EDITED
After reinstalling pyzmq (and I tried reinstalling conda too), the following error occurs:
$ jupyter notebook
Traceback (most recent call last): File
"C:\Users\User\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py",
line 10, in
import sqlite3
File "C:\Users\User\Anaconda3\lib\sqlite3__init__.py", line 23, in
from sqlite3.dbapi2 import *
File "C:\Users\User\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\User\Anaconda3\Scripts\jupyter-notebook-script.py", line 6,
in
from notebook.notebookapp import main
File
"C:\Users\User\Anaconda3\lib\site-packages\notebook\notebookapp.py",
line 86, in
from .services.sessions.sessionmanager import SessionManager
File
"C:\Users\User\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py",
line 13, in
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
I found a similar issue open on GitHub for zmq. The recommendation by GitHub user harsh23tyagi that seems to work for most is to run the following:
pip uninstall pyzmq
pip install pyzmq
Working with conda env, jupyter notebook worked in (base) env but gave the .libzmq error in (my_env).
To be able to run notebooks from my_env, this worked for me :
pip uninstall pyzmq
pip install pyzmq==20 (no version for pyzmq didn't fix the issue for me)
It seems that updating pyzmq to the latest version fixes this problem for me.
conda install pyzmq=22
I just installed Anaconda. I already had Spyder 3.0.0 installed on my Windows 8.1 (64 bit). I also already had Python 3.4 installed. But, after installing Anaconda, I went into Preferences and pointed the Python executable to the Anaconda3 folder to utilize the 3.5 version. But when I started up Spyder again, got the following error:
An error ocurred while starting the kernel
C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\PIL\Image.py:81: RuntimeWarning: The _imaging extension was built for another version of Python.
RuntimeWarning
C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\PIL\Image.py:81: RuntimeWarning: The _imaging extension was built for another version of Python.
RuntimeWarning
Traceback (most recent call last):
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\spyderlib\widgets\externalshell\start_ipython_kernel.py", line 187, in
from ipykernel.kernelapp import IPKernelApp
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\ipykernel\__init__.py", line 2, in
from .connect import *
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\ipykernel\connect.py", line 18, in
import jupyter_client
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\jupyter_client\__init__.py", line 4, in
from .connect import *
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\jupyter_client\connect.py", line 21, in
import zmq
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\__init__.py", line 66, in
from zmq import backend
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\backend\__init__.py", line 40, in
reraise(*exc_info)
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\backend\__init__.py", line 27, in
_ns = select_backend(first)
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\backend\select.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\WinPython󈛤bitð”‚.4.4.2\pythonð”‚.4.4.amd64\lib\site‑packages\zmq\backend\cython\__init__.py", line 6, in
from . import (constants, error, message, context,
ImportError: Module use of python34.dll conflicts with this version of Python.
Any ideas?
Suggestion:
rename your directory "C:\WinPython-64bit-3.4.4.2" in "C:\WinPython-64bit-3.4.4.2bis"
relaunch your Anaconda Spyder
if it doesn't help, rename it back to "C:\WinPython-64bit-3.4.4.2"