Notebook: Getting Kernel Error while running Jupyter Notebook in Python3

Created on 22 Apr 2018  路  41Comments  路  Source: jupyter/notebook

I am getting a kernel error while running Jupyter Notebook in python 3 .On running

Jupyter kernelspeclist
I am getting-
Available kernels:
python3 /home/rishav/.local/share/jupyter/kernels/python3 python2 /usr/local/share/jupyter/kernels/python2
I am running it under tensorflow virtual environment.

Most helpful comment

This is a different issue than the original post and more likely related to #4907. Please first upgrade jupyter_client (e..g, pip install jupyter_client --upgrade) which should bring jupyter_client to 5.3.4 and jupyter_core to 4.6.1. If the issue persists, please provide the relative traceback as there will be additional information provided. Thanks.

All 41 comments

What is the error message?

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1469, in _execute result = yield result

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run value = future.result()

File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result raise_exc_info(self._exc_info)

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1021, in run yielded = self.gen.throw(*exc_info)

File "/usr/local/lib/python2.7/dist-packages/notebook/services/sessions/handlers.py", line 73, in post type=mtype))

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run value = future.result()

File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result raise_exc_info(self._exc_info)

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1021, in run yielded = self.gen.throw(*exc_info)

File "/usr/local/lib/python2.7/dist-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session

kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name) File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run value = future.result()

File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result raise_exc_info(self._exc_info)

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1021, in run yielded = self.gen.throw(*exc_info)

File "/usr/local/lib/python2.7/dist-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run value = future.result()

File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result raise_exc_info(self._exc_info)

File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 285, in wrapper yielded = next(result)

File "/usr/local/lib/python2.7/dist-packages/notebook/services/kernels/kernelmanager.py", line 141, in start_kernel super(MappingKernelManager, self).start_kernel(**kwargs)

File "/usr/local/lib/python2.7/dist-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel km.start_kernel(**kwargs)

File "/usr/local/lib/python2.7/dist-packages/jupyter_client/manager.py", line 257, in start_kernel **kw)

File "/usr/local/lib/python2.7/dist-packages/jupyter_client/manager.py", line 203, in _launch_kernel return launch_kernel(kernel_cmd, **kw)

File "/usr/local/lib/python2.7/dist-packages/jupyter_client/launcher.py", line 128, in launch_kernel proc = Popen(cmd, **kwargs)

File "/usr/lib/python2.7/subprocess.py", line 711, in __init__ errread, errwrite)

File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child raise child_exception

OSError: [Errno 2] No such file or directory

Probably your python3 kernelspec points to a Python executable that no longer exists. Try installing a kernelspec from your tensorflow environment.

in case it might help:
@Rishav09 I had a similar issue after deleting older python version (3.6) and it seems fixed after editing (changing to 3.7) kernel.json in the folder indicated by jupyter kernelspec list

I have a very similar error but only for one specific jupyter notebook file. I have a few jupyter notebook files, all of them open without any problem, but one particular opens in python2 and says kernel error. Terminal shows this error (bottom). I wonder why only this file (Exercise1_atmosphere.ipynb) shows this error? Why not all the other .ipynb files. jupyter kernelspec list returns

Available kernels: python2 /home/astropc/.local/share/jupyter/kernels/python2 python3 /home/astropc/anaconda3/share/jupyter/kernels/python3
and and conda info -a returns

active environment : base
    active env location : /home/astropc/anaconda3
            shell level : 1
       user config file : /home/astropc/.condarc
 populated config files : /home/astropc/.condarc
          conda version : 4.6.8
    conda-build version : 3.17.8
         python version : 3.6.8.final.0
       base environment : /home/astropc/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/astropc/anaconda3/pkgs
                          /home/astropc/.conda/pkgs
       envs directories : /home/astropc/anaconda3/envs
                          /home/astropc/.conda/envs
               platform : linux-64
             user-agent : conda/4.6.8 requests/2.21.0 CPython/3.6.8 Linux/4.15.0-46-generic ubuntu/18.04.2 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

# conda environments:
#
base                  *  /home/astropc/anaconda3
tensorflow-gpu           /home/astropc/anaconda3/envs/tensorflow-gpu
                         /home/astropc/anaconda3/envs/tensorflow-gpu/envs/tensorflow-cpu
tensorflow1.1            /home/astropc/anaconda3/envs/tensorflow1.1
tf                       /home/astropc/anaconda3/envs/tf

sys.version: 3.6.8 |Anaconda, Inc.| (default, Dec 30 ...
sys.prefix: /home/astropc/anaconda3
sys.executable: /home/astropc/anaconda3/bin/python
conda location: /home/astropc/anaconda3/lib/python3.6/site-packages/conda
conda-build: /home/astropc/anaconda3/bin/conda-build
conda-convert: /home/astropc/anaconda3/bin/conda-convert
conda-debug: /home/astropc/anaconda3/bin/conda-debug
conda-develop: /home/astropc/anaconda3/bin/conda-develop
conda-env: /home/astropc/anaconda3/bin/conda-env
conda-index: /home/astropc/anaconda3/bin/conda-index
conda-inspect: /home/astropc/anaconda3/bin/conda-inspect
conda-metapackage: /home/astropc/anaconda3/bin/conda-metapackage
conda-render: /home/astropc/anaconda3/bin/conda-render
conda-server: /home/astropc/anaconda3/bin/conda-server
conda-skeleton: /home/astropc/anaconda3/bin/conda-skeleton
conda-verify: /home/astropc/anaconda3/bin/conda-verify
user site dirs: ~/.local/lib/python2.7
                ~/.local/lib/python3.6

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: base
CONDA_EXE: /home/astropc/anaconda3/bin/conda
CONDA_PREFIX: /home/astropc/anaconda3
CONDA_PROMPT_MODIFIER: (base) 
CONDA_PYTHON_EXE: /home/astropc/anaconda3/bin/python
CONDA_ROOT: /home/astropc/anaconda3
CONDA_SHLVL: 1
DEFAULTS_PATH: /usr/share/gconf/ubuntu.default.path
MANDATORY_PATH: /usr/share/gconf/ubuntu.mandatory.path
PATH: /home/astropc/anaconda3/bin:/home/astropc/anaconda3/condabin:/home/astropc/.iraf/bin:/home/astropc/.iraf/bin:/home/astropc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
PYTHONPATH: :/home/astropc/mzechmeister/python/
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>

After executing jupyter notebook and trying to open the particular notebook

[E 12:50:39.009 NotebookApp] Failed to run command:
    ['/home/astropc/anaconda/envs/py27/bin/python', '-m', 'ipykernel_launcher', '-f', '/run/user/1000/jupyter/kernel-59178951-16a1-4eb9-b8cb-a432bea086b4.json']
        PATH='/home/astropc/anaconda3/bin:/home/astropc/anaconda3/bin:/home/astropc/anaconda3/condabin:/home/astropc/.iraf/bin:/home/astropc/.iraf/bin:/home/astropc/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin'
        with kwargs:
    {'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': '/media/astropc/Data/Universidade/Goettingen/Courses/Stellar_Atmosphere', 'start_new_session': True}

[E 12:50:39.010 NotebookApp] Uncaught exception POST /api/sessions (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/web.py", line 1592, in _execute
        result = yield result
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 73, in post
        type=mtype))
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
        kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
        self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1133, in run
        value = future.result()
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 326, in wrapper
        yielded = next(result)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 160, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 259, in start_kernel
        **kw)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "/home/astropc/anaconda3/lib/python3.6/site-packages/jupyter_client/launcher.py", line 138, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "/home/astropc/anaconda3/lib/python3.6/subprocess.py", line 729, in __init__
        restore_signals, start_new_session)
      File "/home/astropc/anaconda3/lib/python3.6/subprocess.py", line 1364, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: '/home/astropc/anaconda/envs/py27/bin/python': '/home/astropc/anaconda/envs/py27/bin/python'
[W 12:50:39.012 NotebookApp] Unhandled error
[E 12:50:39.013 NotebookApp] {
      "Host": "localhost:8888",
      "Connection": "keep-alive",
      "Content-Length": "103",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Origin": "http://localhost:8888",
      "X-Requested-With": "XMLHttpRequest",
      "X-Xsrftoken": "2|bdb43243|7aed2b4c763872852b3454c22c232997|1550479244",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36",
      "Content-Type": "application/json",
      "Referer": "http://localhost:8888/notebooks/Exercise1_atmosphere.ipynb",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-US,en;q=0.9,de;q=0.8,pt-BR;q=0.7,pt;q=0.6",
      "Cookie": "_xsrf=2|bdb43243|7aed2b4c763872852b3454c22c232997|1550479244; username-localhost-8889=\"2|1:0|10:1551772173|23:username-localhost-8889|44:NmMzMTNiOWYxOWRiNDNjZTgyZGViZDYwOWYwNmUyNmQ=|183bd6c29add25d30c63fe2a85b06797c5fed7cd8338d439987ea5095e689757\"; username-localhost-8888=\"2|1:0|10:1552823434|23:username-localhost-8888|44:MGRlNDc2NjcxMzU5NDAyYjg1OGY3NjFjMTcxYTcwNjM=|84621688074c1716a46c3d23a705d47fc269421c1cc5de649f00f370bbff7f01\""
    }
[E 12:50:39.013 NotebookApp] 500 POST /api/sessions (127.0.0.1) 25.06ms referer=http://localhost:8888/notebooks/Exercise1_atmosphere.ipynb

I think I may have clumsy environments (I'm testing different versions and settings) but I do not understand exactly why only this file shows this problem! Why not all the notebooks? (I am executing everything in the "base" environment, i.e, everything is done after conda activate). conda install jupyter says everything is

@Rishav09
I had a similar error while using tensorflow. I think the problem exists in the path which points to the python executable.
I did 'jupyter kernelspec list' which spit out

Available kernels:
  python3    C:\Users\Manish\Miniconda3\envs\uterm1\share\jupyter\kernels\python3

Upon examining this directory closely I found kernel.json had argv with path to python executable incorrectly stated. It had

{
 "argv": [
  "C:/Users/Manish/Miniconda3/envs/uterm1/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

There was no 'bin' directory but python executable was present directly inside 'uterm1' so i edited the path removing 'bin' to finally include

 "argv": [
  "C:/Users/Manish/Miniconda3/envs/uterm1/python"

in kernel.json

This solved my problem and everything worked as it used to.
Conclusion: Edit the path in kernel.json to correctly point to python executable.
Hope this helps !!

Probably your python3 kernelspec points to a Python executable that no longer exists. Try installing a kernelspec from your tensorflow environment.

This is helpful. Having the same issue in python3, get solved after installing kernelspec.

failed to start kernel
(help me with this)

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\ProgramData\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\ADARSH\AppData\Roaming\jupyter\runtime\kernel-d91d392b-7404-4d79-8393-d5706c60f1ac.json'

This is a different issue than the original post and more likely related to #4907. Please first upgrade jupyter_client (e..g, pip install jupyter_client --upgrade) which should bring jupyter_client to 5.3.4 and jupyter_core to 4.6.1. If the issue persists, please provide the relative traceback as there will be additional information provided. Thanks.

thanks a lot

I have kernel error showing on the right top corner while running the juypter notebook(python 3)
can anyone plzz help me to overcome from this error

@Deepthi-mahadev - The first step would be to check your Notebook server console for any traceback information relative to the time in which your kernel failed. If you see that information, scrape your screen and add that to your next response. Thanks.

im getting kernel error with this kind

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\ProgramData\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\spoorthi\AppData\Roaming\jupyter\runtime\kernel-1a4f7efc-3c05-48ec-ac0b-d066f4283983.json'

You're using the older modules of juypter_client and jupyter_core. Follow the steps to upgrade those modules (above) and please report back results after that upgrade and restarting your Notebook server. If failures still occur, it's likely an issue with a mounted filesystem.

Its throwing an environemental error and its asking to use --user or to change the permission

Hmm - I'm not familiar with that message. Might you be able to provide the actual message and any surrounding information that might be pertinent.

If you've correctly updated the modules, you should see that secure_write is coming from jupyter_core rather than jupyter_client as your traceback shows above. That's why I asked for the updated traceback information. We're not going to get new/useful information until you see the issue stemming from jupyter_core (if at all).

Hi there im getting this kernel error in jupyter notebook....can anybody help me with this

Traceback (most recent call last):
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\Sunny\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\Users\Sunny\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\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Sunny\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\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Sunny\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\Sunny\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\Users\Sunny\Anaconda3\lib\site-packagesjupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\Users\Sunny\Anaconda3\lib\site-packagesjupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\Sunny\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\Sunny\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Sunny\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\Sunny\Anaconda3\lib\site-packagesjupyter_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\Sunny\AppData\Roaming\jupyter\runtime\kernel-4643d574-654e-49d8-9b1a-6e17d124b3de.json'

Please start with this comment.

Please start with this comment.

Thanks for help it worked for me.... much appreciated!

Please start with this comment.

Thanks for help it worked for me.... much appreciated!

but now im getting this error on jupyter notebook while i try to load this paticular file ("supermarkets.cvs") plz help again........


AttributeError Traceback (most recent call last)
in
----> 1 df1=pandas.read("supermarkets")
2 df1

~\Anaconda3\lib\site-packages\pandas__init__.py in __getattr__(name)
212
213 return Panel
--> 214 raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
215
216

AttributeError: module 'pandas' has no attribute 'read'

Just googling pandas, I think you might want ...

df1 = pandas.read_csv("supermarkets.csv")

but that's the extent of my pandas knowledge.

@Sunny0002 - should you still have issues with your pandas code and you believe there's a relation to notebook, please open a completely new issue since this is unrelated to this particular issue regarding kernel startup.

Just googling pandas, I think you might want ...

df1 = pandas.read_csv("supermarkets.csv")

but that's the extent of my pandas knowledge.

@Sunny0002 - should you still have issues with your pandas code and you believe there's a relation to notebook, please open a completely new issue since this is unrelated to this particular issue regarding kernel startup.

yup.....Googled it... everything working fine at the moment.....

Getting Kernel Error while running Jupyter Notebook in Python3

Traceback (most recent call last):
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\Users\INCT-ParthVats\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\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\INCT-ParthVats\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\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packagesjupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packagesjupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 547, in write_connection_file
sock = self.context.socket(socket_type)
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 212, in write_connection_file
else:
File "C:\Users\INCT-ParthVats\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\INCT-ParthVats\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 102, in secure_write
sock.bind((ip, 0))
PermissionError: [Errno 13] Permission denied: 'C:\Users\INCT-ParthVats\AppData\Roaming\jupyter\runtime\kernel-d17eaab9-0f90-4f07-8455-9a4e72d6da38.json'

Please start with this comment.

mostly the problem is with admin of the PC. please Run Anaconda with Admin permission, kernel issue will resolve

Traceback (most recent call last):
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\Users\Toyosi\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\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\Toyosi\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\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\Toyosi\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\Users\Toyosi\Anaconda3\lib\site-packagesjupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\Users\Toyosi\Anaconda3\lib\site-packagesjupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\Toyosi\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\Toyosi\Anaconda3\lib\site-packagesjupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Toyosi\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\Toyosi\Anaconda3\lib\site-packagesjupyter_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\Toyosi\AppData\Roaming\jupyter\runtime\kernel-e348c042-09fd-46fd-b4f5-359abd09d46e.json'

even after [pip install jupyter_client --upgrade] it doesnt still work
my kernel error still shows that

Hi. I am trying to install R and use it on Jupyter Notebook but i am getting the following error on Jupyter:

A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.

@sidneyaburi - this message implies that the front-end (browser) has lost its connection to the Notebook server. If the Notebook server console (or log) does not contain traceback information similar to what is listed above, could you please open a NEW issue relative to this? Issues should track related problems, and there's no indication that your issue is related. If you do need to open a new issue, please include the complete notebook console (or log) contents in that new issue so myself or others can help you.

Thanks.

Traceback (most recent call last):
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\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\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\manager.py", line 258, in start_kernel
self.kernel = self._launch_kernel(kernel_cmd, env=env,
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, *
kw)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\launcher.py", line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

kernel error am lost here reinstalled but the same problem. even when i start a brand new file same error

@BurhanAHanif - You might try taking a look at https://github.com/jupyter/notebook/issues/2301#issuecomment-287119893 and the surrounding comments/instructions.

@kevin-bates your a life saver sir. felt like putting my head through a wall

This is a different issue than the original post and more likely related to #4907. Please first upgrade jupyter_client (e..g, pip install jupyter_client --upgrade) which should bring jupyter_client to 5.3.4 and jupyter_core to 4.6.1. If the issue persists, please provide the relative traceback as there will be additional information provided. Thanks.

Whoa! That helped a lot. Thank you very much

Few days ago, my notebooks worked, but today it had the issue., but my R kernel and Julia kernel still work perfectly.
I wonder if it's related to ipython or ipykernel. l've reinstalled both, but still didnt worked.

Hi @Jejulia - Sounds like you're on the right track. What kinds of things are you seeing in your notebook server's console (or log if redirected) when attempting to start a python kernel?

Traceback (most recent call last):
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\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\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(
kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\manager.py", line 258, in start_kernel
self.kernel = self._launch_kernel(kernel_cmd, env=env,
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, kw)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\site-packagesjupyter_client\launcher.py", line 138, in launch_kernel
proc = Popen(cmd, *
kwargs)
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\subprocess.py", line 854, in **init

self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\19174\Anaconda3\envs\pyfinance\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

first you use-->(eg. pip install jupyter_client --upgrade) if it is getting permission error.
then you use-->(eg. pip install jupyter_client --upgrade --user)

Hi, I am getting a similar error on Jupyter Notebook, and unable to start kernel. I have tried the above solution of upgrading the jupyter client but to no avail. Can anyone help me.?

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(
exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(exc_info) # type: ignore
File "C:\ProgramData\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:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packagesjupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(
kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packagesjupyter_client\manager.py", line 308, in start_kernel
self.kernel = self._launch_kernel(kernel_cmd, *
kw)
File "C:\ProgramData\Anaconda3\lib\site-packagesjupyter_client\manager.py", line 215, in _launch_kernel
return launch_kernel(kernel_cmd, *kw)
File "C:\ProgramData\Anaconda3\lib\site-packagesjupyter_client\launcher.py", line 135, in launch_kernel
proc = Popen(cmd, *
kwargs)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
NotADirectoryError: [WinError 267] The directory name is invalid

Hi @gogoiuddipta - this still sounds like an issue of sorts with the kernel.json file that describes the kernel's startup command, env, etc.

I recommend using jupyter kernelspec list to locate the kernel's directory and take a careful look at the kernel.json file. In particular, the argv stanza, since it's that command that is being fed to the Popen() method in your traceback. Perhaps it contains a space-separated path that isn't quoted or something that might confuse windows into thinking there's an invalid directory name, etc.

Should you not find what's going on, please feel free to post the contents of kernel.json here in case others might be able to help or learn from it.

This is a different issue than the original post and more likely related to #4907. Please first upgrade jupyter_client (e..g, pip install jupyter_client --upgrade) which should bring jupyter_client to 5.3.4 and jupyter_core to 4.6.1. If the issue persists, please provide the relative traceback as there will be additional information provided. Thanks.

Traceback (most recent call last):
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\web.py", line 1703, in _execute
    result = await result
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
    model = yield maybe_future(
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\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\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
    kernel_id = yield maybe_future(
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 176, in start_kernel
    kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
    km.start_kernel(**kwargs)
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_client\manager.py", line 304, in start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_client\manager.py", line 251, in pre_start_kernel
    self.write_connection_file()
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_client\connect.py", line 468, in write_connection_file
    self.connection_file, cfg = write_connection_file(self.connection_file,
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
    with secure_write(fname) as f:
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_core\paths.py", line 435, in secure_write
    win32_restrict_file_to_user(fname)
  File "c:\users\lenovo\anaconda3\envs\tensorflow1\lib\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: The specified module could not be found.

Thats my issue , do help me out

A quick search through the issues shows this is a duplicate of #5090 (and #5338 among others) although your jupyter_client and jupyter_core packages appear relatively up to date, so I'd focus on the conda install pywin32 aspect. You might also find this comment helpful: https://github.com/jupyter/notebook/issues/5235#issuecomment-587545067.

@Rishav09
I had a similar error while using tensorflow. I think the problem exists in the path which points to the python executable.
I did 'jupyter kernelspec list' which spit out

Available kernels:
  python3    C:\Users\Manish\Miniconda3\envs\uterm1\share\jupyter\kernels\python3

Upon examining this directory closely I found kernel.json had argv with path to python executable incorrectly stated. It had

{
 "argv": [
  "C:/Users/Manish/Miniconda3/envs/uterm1/bin/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

There was no 'bin' directory but python executable was present directly inside 'uterm1' so i edited the path removing 'bin' to finally include

 "argv": [
  "C:/Users/Manish/Miniconda3/envs/uterm1/python"

in kernel.json

This solved my problem and everything worked as it used to.
Conclusion: Edit the path in kernel.json to correctly point to python executable.
Hope this helps !!

Thank you @manishgrd!! This was what finally got thing things working for me:

Switching

{
 "argv": [
  "/usr/local/opt/python/bin/python3.7",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

to

{
 "argv": [
  "/usr/local/opt/python/bin/python3.8",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

i.e., changing "3.7" to "3.8" in ~/Library/Jupyter/kernels/python3/kernel.json

To help the googlers out there, the error I was getting before was this: FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/opt/python/bin/python3.7'

Was this page helpful?
0 / 5 - 0 ratings