Confusing error when attempting to start the Jupyter notebook - python-3.x

The following output appeared when I was attempting to start an instance of the Jupyter botebook:
C:\Users\CaitlinG>jupyter notebook
Traceback (most recent call last):
File "c:\users\caitling\appdata\local\programs\python\python35\lib\runpy.py",
line 184, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\caitling\appdata\local\programs\python\python35\lib\runpy.py",
line 85, in _run_code
exec(code, run_globals)
File "C:\Users\CaitlinG\AppData\Local\Programs\Python\Python35\Scripts\jupyter
-notebook.exe\__main__.py", line 5, in <module>
File "c:\users\caitling\appdata\local\programs\python\python35\lib\site-packag
es\notebook\notebookapp.py", line 31, in <module>
from zmq.eventloop import ioloop
File "c:\users\caitling\appdata\local\programs\python\python35\lib\site-packag
es\zmq\__init__.py", line 37, in <module>
_libzmq = ctypes.cdll.LoadLibrary(bundled[0])
File "c:\users\caitling\appdata\local\programs\python\python35\lib\ctypes\__in
it__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "c:\users\caitling\appdata\local\programs\python\python35\lib\ctypes\__in
it__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I am using Windows 10 and Python 3.5.2. I installed the package, along with its dependencies, via: pip3 install "ipython[notebook]" --upgrade
The aforementioned process proceeded without incident but I am confused why the issue has appeared.
Thanks.

It seems to be an issue with pyzmq 15.3. Installing a previous version worked for me:
pip install pyzmq==15.2
See:
https://github.com/jupyter/help/issues/62
Good luck!

Related

Kernel error: ipykernel NotImplementedError

Error Message
Traceback (most recent call last):
File "G:\anaconda\envs\jup\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "G:\anaconda\envs\jup\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "G:\anaconda\envs\jup\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 448, in initialize self.init_sockets()
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 251, in init_sockets
self.init_iopub(context)
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 259, in init_iopub self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True)
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 63, in __init__
self._setup_pipe_in()
File "C:\Users\sk_np\AppData\Roaming\Python\Python38\site-packages\ipykernel\iostream.py", line 126, in _setup_pipe_in
self._pipe_in = ZMQStream(pipe_in, self.io_loop)
File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
self._init_io_state()
File "G:\anaconda\envs\jup\lib\site-packages\zmq\eventloop\zmqstream.py", line 552, in _init_io_state
self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
File "G:\anaconda\envs\jup\lib\site-packages\tornado\platform\asyncio.py", line 100, in add_handler
self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
File "G:\anaconda\envs\jup\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
Conda Environment Info:
jupyter-client:7.1.2
jupyter_client:5.3.1
python:3.8.0
I tried This Github Issue and followed the steps of This stackoverflow post.
Reproduction steps:
Install anaconda3
create conda env with conda create -n env python=3.8
conda install -c anaconda jupyter
jupyter notebook
You have apparently anaconda installed, but also a seperate python installation, see how both C:\Users\sk_np\AppData\Roaming\Python\Python38 and G:\anaconda show up in your traceback. This is probably causing the issue due to inconsistencies in the packages. The simplest step, and the one that will save you a lot of headache in the future, would be to uninstall the python that you have at
C:\Users\sk_np\AppData\Roaming\Python\Python38
Additionally, run in your anaconda prompt (from which you tried to start jupyter)
jupyter kernelspec list
and then remove the kernel that is at C:\Users\sk_np\AppData\Roaming\Python\Python38 with
jupyter kernelspec remove <kernelName>

pyenv BUILD FAILED while trying (pyenv install -v 3.9.0) on wsl2 ubuntu 20.04

SOLVED: the solution was I needed zlib1g-dev
This is the error pyenv produces
Traceback (most recent call last):
File "<frozen zipimport>", line 520, in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen zipimport>", line 568, in _get_data
File "<frozen zipimport>", line 523, in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 206, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 147, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 709, in _get_module_code
File "<frozen zipimport>", line 570, in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Traceback (most recent call last):
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 210, in _main
return _bootstrap(
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 129, in _bootstrap
return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/ensurepip/__init__.py", line 38, in _run_pip
return subprocess.run([sys.executable, "-c", code], check=True).returncode
File "/tmp/python-build.20201212114143.1082/Python-3.9.0/Lib/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/python-build.20201212114143.1082/Python-3.9.0/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpk898xfhs/setuptools-49.2.1-py3-none-any.whl\', \'/tmp/tmpk898xfhs/pip-20.2.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpk898xfhs\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make: *** [Makefile:1254: install] Error 1
I have found nothing on this when googling and have no idea what is going on.
the steps that I have done are, first installing the pyenv installer and running that script then trying to run (pyenv install -v 3.9.0)
the system does have python3.8 installed and pyenv does seem to know about it
but it still will not let me install 3.9.0
EDIT: I should also throw in that in order to let pyenv know about the system version of python I did this (sudo ln -s /usr/bin/python3 /usr/bin/python).
Another thing is I also tried installing 3.9.0 with a tool called asdf and that resulted in the same error
EDIT2: It seems like im missing zlib from the traceback but Im on ubuntu and do have zlib1g installed and from what I looked up thats what zlib is on ubuntu 20.04 im going to try and find more info on the zlib and see if I need to install something else
I had a similar problem trying to install Python 3.8 with asdf (which uses the same backend as pyenv) on WSL2/Ubutnu18, and installing zlib1g-dev was not enough to solve it as stated by the question's author.
Therefore, as a more general solution, I have found that installing all dependencies recommended by pyenv for Ubuntu did solve the problem for asdf (and I suspect for pyenv as well). The dependencies for different OS can be found here: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
I hope this is useful for others!
PS: This resource might be useful as well for similar issues: https://github.com/pyenv/pyenv/wiki/Common-build-problems

Why can't Jupyter notebook open Kernel?

I recently installed Jupyter on a new computer and after trying with and without virtualenv, I receive the following errors related to the threading module. This error prevents the notebook from either (1) opening or (2) starting the kernel.
Error upon opening python -m notebook. Notebook doesn't open successfully.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/nbextensions.py", line 31, in <module>
from .config_manager import BaseJSONConfigManager
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/notebook/config_manager.py", line 15, in <module>
from traitlets.config import LoggingConfigurable
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/traitlets/config/__init__.py", line 6, in <module>
from .application import *
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/traitlets/config/application.py", line 11, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 210, in <module>
_lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'
Exception ignored in: <module 'threading' from '/Users/me/Downloads/threading.py'>
AttributeError: module 'threading' has no attribute '_shutdown'
Error after switching directory, opening notebook successfully, and attempting to connect to kernel
[I 09:32:05.828 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/Users/me/Documents/Code/Python/Environments/Jupyter/lib/python3.7/site-packages/IPython/core/application.py", line 18, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 210, in <module>
_lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'
Exception ignored in: <module 'threading' from '/Users/me/Downloads/threading.py'>
AttributeError: module 'threading' has no attribute '_shutdown'
Seeing as threading is a built-in module, I cannot update it. Again, this result is identical using the normal site-packages installation and a clean virtualenv installation.
I found that this error was caused because a file named threading.py (not related to the built-in module) existed in a subdirectory of my home directory. If I launched the notebook from any directory where the file was anywhere in the directory tree below my current directory, I would receive this error.
The solution is to launch the notebook in a directory where a naming conflict with the built-in threading does not exist.
The odd thing is that if I import threading in a Python shell in the same directories where the failures occurred and run dir(threading), it picks up the correct package. Why does Jupyter treat this differently?

Why am I getting invalid syntax error while installing packages with pip

In Debian server when I am installing boto3 using pip I get the following error:
$ python3.2 -m pip install boto3
Traceback (most recent call last):
File "/usr/lib/python3.2/runpy.py", line 161, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python3.2/runpy.py", line 74, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.2/dist-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/cli/cmdoptions.py", line 17, in <module>
from pip._internal.locations import USER_CACHE_DIR, src_prefix
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/locations.py", line 13, in <module>
from pip._internal.utils import appdirs
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/utils/appdirs.py", line 12, in <module>
from pip._internal.utils.compat import WINDOWS, expanduser
File "/usr/local/lib/python3.2/dist-packages/pip/_internal/utils/compat.py", line 62
return u"".join(u"\\x%x" % c for c in raw_bytes), err.end
^
SyntaxError: invalid syntax
Note: pip version is 18.1
I figured it out. The syntax - u"".join is not supported in python3.2.
pip3(which was same as pip3.2) while running the scripts for installing boto3 faced the syntax and threw the exception.
I installed python 3.6 and on running "pip3.6 install boto3", it worked.
Note: My python project is new and small one, so changing from python3.2 to python3.6 did not affect much, but with large or existing project this may not be feasible. Just want anyone who may face the situation to know the reason for this issue.

pip/tensorflow stopped working on upgrade: enum error

The last thing I tried doing was upgrading tensorflow manually on the cmd line:
pip install --user tensorflow==1.4.1
After the update, I keep getting this error, I can not use pip for any other installs or run any code with tensorflow:
Traceback (most recent call last):
File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python36\Scripts\pip.exe\__main__.py", line 2, in <module>
File "c:\python36\lib\re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
How do I fix this?

Resources