Kernel error: ipykernel NotImplementedError - python-3.x

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>

Related

Jupyter notebook is not opening

I have installed anaconda package and my pc has already one package installed "root(data analysis package)".
So after installing anaconda I wanted to open jupyter notebook so I type "jupyter-notebook" in the terminal but somehow I am getting following error.
Could you please provide me a solution for this? Thanks.
the error
Traceback (most recent call last):
File "/home/souvik/anaconda3/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 264, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.initialize(argv)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 88, in inner
return method(app, *args, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 2143, in initialize
super().initialize(argv)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 88, in inner
return method(app, *args, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 239, in initialize
self.migrate_config()
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 165, in migrate_config
migrate()
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/migrate.py", line 245, in migrate
with open(os.path.join(env['jupyter_config'], 'migrated'), 'w', encoding='utf-8') as f:
PermissionError: [Errno 13] Permission denied: '/opt/root/6.26.10-install/etc/notebook/migrated'*
I could not find any solution in google for this.
After a glimpse at the error Message,
You seem not to have access to /opt/root/6.26.10-install/etc/notebook/migrated
How did you install the anaconda? (globally or on root?)
since you are currently running as user "souvik"
Try running:
sudo jupyter-notebook --allow-root
Then post back the results.
In case the above command started jupypter-notebook successfully,
we can change the ownership of /opt/root/6.26.10-install/etc/notebook/from rootto you (souvik) using chown.

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

Kernel error in spyder and jupyter notebook

I tried to use the Anaconda Navigator, but I'm getting this kernel error.
I had previously installed python 3.8 without Anaconda and had installed jupyter in it using pip, then I uninstalled it and installed Anaconda again.
Since then this error arises whenever I try to compile a file and even in the jupyter notebook.
I tried :
1.) Reinstalling Anaconda
2.) Updating the setup tools
None of these worked.
Traceback (most recent call last):
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\DELLL\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\DELLL\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\DELLL\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\DELLL\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\DELLL\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\DELLL\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\DELLL\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\DELLL\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 102, in secure_write
with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\DELLL\\AppData\\Roaming\\jupyter\\runtime\\kernel-4058ed7c-98d6-40c9-8b3b-2cbb069740d8.json'
Issue resolved.
The problem:
I had previously installed jupyter using pip install, when I was working on python 3.8.
Now, I uninstalled python 3.8 and installed Anaconda instead. This again reinstalled jupyter, thus was the cause of the problem.
To resolve this, I uninstalled jupyter from AnacondaPrompt using conda uninstall jupyter , and then reinstalled it, this time from conda install jupyter.
This resolved the kernel error.
This is permission issue for that particular folder
Set the environment path variables C:\Users\DELL\AppData\Roaming\jupyter\runtime
give the permission and it will work

Tensorflow breaks pip on anaconda, windows os

Last version of anaconda, windows 10, python 3.6.
Installing tensorflow seems to break pip.
>conda create -n py6 python=3.6
>activate py6
>conda install tensorflow
>pip install tweepy
Collecting tweepy
Exception:
Traceback (most recent call last):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Use of tweepy is just an example, pip cannot install any package.
The same happens when installing tensorflow using pip, and when using a python 3.5 virtual environment.
Probably this is due to some package update gone wrong, and it will be fixed in the next update.
Meanwhile, any fix or any careful selection of working version numbers is welcome.
This issues is reported in the following ticket : https://github.com/tensorflow/tensorboard/issues/588
To solve this, you need to repair html5lib.
Or alternatively,
you can make use of anaconda to re-install
conda install -c anaconda html5lib

Confusing error when attempting to start the Jupyter notebook

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!

Resources