Kernel error in spyder and jupyter notebook - python-3.x

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

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.

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>

PermissionError: [Errno 13] Permission denied Jupyter notebook on Windows 10 with proxy

I am trying to use jupyter notebook with Python 3.7 on Windows10 for work and am running behind my office network proxy. I was able to run the notebook all fine till a few days ago. Now it keeps showing that the kernel is dead whenever I open the notebook. I get this error to be specific:
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\shreeya.mody\AppData\Local\Continuum\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\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\shreeya.mody\AppData\Local\Continuum\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\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\shreeya.mody\AppData\Local\Continuum\anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\shreeya.mody\AppData\Local\Continuum\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\\shreeya.mody\\AppData\\Roaming\\jupyter\\runtime\\kernel-0068da95-ca03-4be1-b2c0-4814f6f887f3.json'
What I have tried
I have exhausted all the solutions online but nothing so far has worked for me
Checked permission for files. Looks correct to me
Uninstalled and reinstalled Anaconda multiple times
Installed anaconda on a work VM to duplicate the error but it works fine there which makes me think that the error is connected to the kernel files somehow that I cannot point at.
Started notebook from Anaconda Prompt
I want to work on Jupyter notebook on my local machine but no solution I have come across works for me.
The command line commands from the comments help:
conda clean -tipsy
conda uninstall jupyter
conda install jupyter
But after the lines the conda environment is almost completely empty. In my case I needed to install numpy and pandas libraries.

Kernel error: jupyter_client/connect.py AssertionError

Error message
Traceback (most recent call last):
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/web.py", line 1699, in _execute
result = await result
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/djan/anaconda3/lib/python3.7/site-packages/notebook/services/sessions/handlers.py", line 72, in post
type=mtype))
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/djan/anaconda3/lib/python3.7/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 "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "/home/djan/anaconda3/lib/python3.7/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 "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/djan/anaconda3/lib/python3.7/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/home/djan/anaconda3/lib/python3.7/site-packages/notebook/services/kernels/kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/home/djan/anaconda3/lib/python3.7/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/home/djan/anaconda3/lib/python3.7/site-packages/jupyter_client/manager.py", line 240, in start_kernel
self.write_connection_file()
File "/home/djan/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "/home/djan/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "/home/djan/anaconda3/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/home/djan/anaconda3/lib/python3.7/site-packages/jupyter_client/connect.py", line 105, in secure_write
assert '0600' == oct(stat.S_IMODE(os.stat(fname).st_mode)).replace('0o', '0')
AssertionError
System information
Running Jupyter (v. 1.0.0) on a Linux server, with anaconda3 (v. 2019.07) 64-bit.
Available Kernels
Available kernels:
python3 /home/djan/.local/share/jupyter/kernels/python3
nn /home/djan/.local/share/jupyter/kernels/nn
Reproducing the issue
Install the newest anaconda3 version.
Run Jupyter notebook in the base version --> Kernel runs fine
Create a new environment with python: conda create -n test python=3.7
After activating the environment, Jupyter notebook is not available, thus I must install it via Conda: conda install -c anaconda jupyter
Run Jupyter notebook in the test environment --> Kernel breaks down as explained above
What I tried so far
There seems to be an issue with file permissions when running Jupyter on a server inside a Conda environment. I tried to give all files inside my anaconda3 folder the requested permissions (0600), but this did not help.
Update
It turns out that the newest version of jupyter_client, available under anaconda as version 5.3.3, breaks the Jupyter environment on a server.
Installing the previous version of jupyter_client via following command fixes this issue:
conda install -c anaconda jupyter_client=5.3.1
nice
Update
It turns out that the newest version of jupyter_client, available under anaconda as version 5.3.3, breaks the Jupyter environment on a server.
Installing the previous version of jupyter_client via following command fixes this issue:
conda install -c anaconda jupyter_client=5.3.1

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

Resources