Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernal Error - FileNotFoundError: [WinError 2] The system cannot find the file specified #4079

Closed
erfannariman opened this issue Oct 8, 2018 · 36 comments

Comments

@erfannariman
Copy link

When I create a new env in Anaconda: conda create -n envname python=3.6

Then I install jupyter notebook: conda install jupyter notebook

When I start the jupyter notebook and create a new python3 I get the following Error:

Traceback (most recent call last):
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\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 "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\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 "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 326, in wrapper
    yielded = next(result)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

And this is the error message in the Anaconda prompt:

Failed to run command:
    ['C:/Users/ErfanNariman/Anaconda3/envs/blockchain_coney/bin/python', '-m', 'ipykernel_launcher', '-f', 'C:\\Users\\ErfanNariman\\AppData\\Roaming\\jupyter\\runtime\\kernel-6f106cea-2eb2-4a55-a46c-6265ce62c9ae.json']
        PATH='C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Library\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Library\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Library\\mingw-w64\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Library\\usr\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Library\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\Scripts;C:\\Users\\ErfanNariman\\Anaconda3\\envs\\blockchain_coney\\bin;C:\\Users\\ErfanNariman\\Anaconda3;C:\\Users\\ErfanNariman\\Anaconda3\\Library\\mingw-w64\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\Library\\usr\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\Library\\bin;C:\\Users\\ErfanNariman\\Anaconda3\\Scripts;C:\\Users\\ErfanNariman\\Anaconda3\\bin;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Program Files\\ImageMagick-6.9.10-Q8;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\IBM\\SPSS\\Statistics\\24\\JRE\\bin;C:\\Program Files (x86)\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\DTS\\Binn\\;C:\\Program Files (x86)\\Microsoft SQL Server\\140\\Tools\\Binn\\ManagementStudio\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\140\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\140\\DTS\\Binn\\;C:\\Program Files\\PuTTY\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\;C:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python37\\;C:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\;C:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python37-32\\;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Users\\ErfanNariman\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\ErfanNariman\\AppData\\Local\\atom\\bin;C:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python36\\Scripts;C:\\Python34\\ScriptsC:\\Users\\ErfanNariman\\AppData\\Local\\Programs\\Python\\Python3'
        with kwargs:
    {'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': 'C:\\Users\\ErfanNariman\\OneDrive - Coney\\Coney\\Projecten\\Blockchain Reader\\Jupyter Notebooks'}

[E 16:08:41.913 NotebookApp] Uncaught exception POST /api/sessions (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\web.py", line 1592, in _execute
        result = yield result
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
        value = future.result()
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
        type=mtype))
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
        value = future.result()
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\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 "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
        value = future.result()
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1141, in run
        yielded = self.gen.throw(*exc_info)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\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 "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 1133, in run
        value = future.result()
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\tornado\gen.py", line 326, in wrapper
        yielded = next(result)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
        km.start_kernel(**kwargs)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
        **kw)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
        return launch_kernel(kernel_cmd, **kw)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
        proc = Popen(cmd, **kwargs)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\subprocess.py", line 709, in __init__
        restore_signals, start_new_session)
      File "C:\Users\ErfanNariman\Anaconda3\envs\blockchain_coney\lib\subprocess.py", line 997, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified
[W 16:08:41.935 NotebookApp] Unhandled error
[E 16:08:41.941 NotebookApp] {
      "Host": "localhost:8888",
      "Connection": "keep-alive",
      "Content-Length": "110",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Origin": "http://localhost:8888",
      "X-Requested-With": "XMLHttpRequest",
      "X-Xsrftoken": "2|f2baeb02|309bac39d88ac348715520f8169c964a|1537110697",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
      "Content-Type": "application/json",
      "Referer": "http://localhost:8888/notebooks/Jupyter%20Notebooks/Untitled1.ipynb?kernel_name=python3",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-US,en;q=0.9,nl;q=0.8",
      "Cookie": "_xsrf=2|f2baeb02|309bac39d88ac348715520f8169c964a|1537110697; username-localhost-8889=\"2|1:0|10:1537622338|23:username-localhost-8889|44:ZDQ1MTEyNmY5MTVkNGI3ZmI1YzYzNTE0YjgxOWFlYmU=|cf192a93498919bb4ff15eb3cec7cdf059bf955113ad75a59b38e26a158332a4\"; username-localhost-8888=\"2|1:0|10:1539007711|23:username-localhost-8888|44:YWIzYjgwMGI4M2EwNGI4MzkzYmEwMWY5M2YzZTk2MmY=|1b9a5c3e539d8879ec0a16620fc1332ff37ee906a6fa7caca69496db9a1c97e0\""
```

Does anyone know how I can fix this?
@huiguo2008
Copy link

I have exact the same problem.
python 3.7 Jupyter 1.0

@huiguo2008
Copy link

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

@erfannariman
Copy link
Author

erfannariman commented Oct 14, 2018

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

I looked and it was already like this:

{ "argv": [ "C:\\Users\\ErfPy\\Anaconda3\\python.exe" ", "-m", "ipykernel_launcher", "-f", "{connection_file}" ], "display_name": "Python 3", "language": "python" }

So this is not the problem on my side. I agree that it somehows gets the wrong kernel..

@visr
Copy link

visr commented Oct 14, 2018

open the file "kernel.json", and set the "argv": the python path for example.

Yeah thanks, this fixed it for me. I had never touched this file manually before, but noticed that there was an extra bin folder there, if I correct the path it works.

  • "C:/bin/Miniconda3/bin/python" doesn't work
  • "C:/bin/Miniconda3/python" works

Wonder how this path was wrongly set though.

jupyter                   1.0.0                      py_1    conda-forge
jupyter_client            5.2.3                      py_1    conda-forge
jupyter_console           6.0.0                      py_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge

@erfannariman
Copy link
Author

erfannariman commented Oct 14, 2018

For anyone interested, I found the solution:

  1. Open your Anaconda Prompt.
  2. Activate your env (this step is optional if you dont work with envs)
  3. run: python -m ipykernel install --user
  4. Start your jupyter notebook

@scimax
Copy link

scimax commented Nov 6, 2018

  • "C:/bin/Miniconda3/bin/python" doesn't work
  • "C:/bin/Miniconda3/python" works

Wonder how this path was wrongly set though.

I had exactly the same issue - still wondering how the wrong path got into the kernel.json.

@leroygr
Copy link

leroygr commented Nov 8, 2018

I had the same issue in a conda environment that was using a different version of Python (Python 3.6.6) than the base (Python 3.7.0) environment. Running python -m ipykernel install --user did solve the issue.

@clayms
Copy link

clayms commented Nov 8, 2018

This is what fixed it for me:

#2301 (comment)

@Brainor
Copy link

Brainor commented Dec 23, 2018

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

yes, this fixes this issue for me. I ran into this problem because I uninstalled Anaconda and installed Miniconda, but the /python/share/jupyter/kernels/kernel.json file doesn't update the python.exe location.

@Sajjadmanal
Copy link

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

It Worked. Thanks..!!

@ctivanovich
Copy link

Installing ipykernel at the user level with pip as suggested above worked for me--I followed Anaconda's suggestion to install anaconda at the user level, but it seems it doesn't automatically place the kernel.json file where it's needed in that case: C:\Users\User\AppData\Roaming\jupyter\kernels\python3. One could probably just copy the file over from C:\Users\User\Anaconda3\share\jupyter\kernels\python3.

@pybokeh
Copy link

pybokeh commented Apr 30, 2019

Using Miniconda3 for the first time today and got the exact same issue.

python -m ipykernel install --user

fixed for me.

@cemanughian
Copy link

I had this problem in PyCharm as well. Just restarting it fixes the error in this case.

@kkairu
Copy link

kkairu commented Jan 10, 2020

Using Miniconda3 for the first time today and got the exact same issue.

python -m ipykernel install --user

fixed for me.

Works for me. Struggled with the issue for over 2 hrs. :(

@shiva-karthick
Copy link

For anyone facing this issue like this error
FileNotFoundError: [WinError 2] The system cannot find the file specified

This works on Windows : python -m ipykernel install --user

@TeHanHunter
Copy link

For anyone interested, I found the solution:

Open your Anaconda Prompt.
Activate your env (this step is optional if you dont work with envs)
type this: python -m ipykernel install --user
Start your jupyter notebook

Thank you so much! worked for me on python 3.8.1

@SaurabhTripathi62
Copy link

it worked when i created a env but in base its still same. atleast it start working thanks everyone
@TeHanHunter if u find how base env can work please do share

@hdavid16
Copy link

hdavid16 commented Jun 5, 2020

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

On Windows systems, you will need to use double slashes (\) instead of single ones ()

@axat1
Copy link

axat1 commented Oct 7, 2020

@hdavid16
I tried this and changed my kernel.json

{
 "argv": [
  // "E:/Jupyter/miniconda3/envs/axat/bin/python",
  "E:/Jupyter/miniconda3/envs/axat/python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3",
 "language": "python"
}

but now i got this new error :

Traceback (most recent call last):
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\web.py", line 1703, in _execute
    result = await result
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\envs\axat\lib\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 "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "E:\Jupyter\miniconda3\envs\axat\lib\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 "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\manager.py", line 246, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\manager.py", line 170, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\manager.py", line 82, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\kernelspec.py", line 238, in get_kernel_spec
    return self._get_kernel_spec_by_name(kernel_name, resource_dir)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\kernelspec.py", line 201, in _get_kernel_spec_by_name
    return self.kernel_spec_class.from_resource_dir(resource_dir)
  File "E:\Jupyter\miniconda3\envs\axat\lib\site-packages\jupyter_client\kernelspec.py", line 47, in from_resource_dir
    kernel_dict = json.load(f)
  File "E:\Jupyter\miniconda3\envs\axat\lib\json\__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "E:\Jupyter\miniconda3\envs\axat\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "E:\Jupyter\miniconda3\envs\axat\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "E:\Jupyter\miniconda3\envs\axat\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 3 column 3 (char 15)

I really appreciate if someone can help me. Thank you :)

Edit

I just deleted the comment part and it worked for me. @hdavid16 thanx for the help.

@mofumeister
Copy link

mofumeister commented Dec 7, 2020

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

To add to this solution: if you're still encountering issues try \\ instead of \
So "C:\ProgramData\Anaconda3\python.exe" should be "C:\\ProgramData\\Anaconda3\\python.exe"

@rpgoldman
Copy link

FWIW, I'm on Mac and I just had this problem, and installing ipykernel as --user did not fix the problem. There's nothing obviously wrong with my kernel.json file, either (unlike for @mofumeister, my python path is correct, and there's no issue of backslashes in command strings)

@ArnaudMallet
Copy link

Hi Everyone,

In case someone still have this problem, I solved this issue with the below

  1. Start a prompt
  2. Activate the environment
  3. Run python -m ipykernel install --user
  4. Run jupyter notebook

Python = 3.9.1 / Jupyter Lab 3.0.7

Now everything works smoothly

@kannes
Copy link

kannes commented Feb 8, 2021

This still is a bug though, right? https://jupyter.org/install does not mention this step so it should not be necessary.

@adarsharegmi
Copy link

python -m ipykernel install --user solved for me too..........

@himanshu-irl
Copy link

For anyone interested, I found the solution:

Open your Anaconda Prompt.
Activate your env (this step is optional if you dont work with envs)
type this: python -m ipykernel install --user
Start your jupyter notebook

This worked for me. Thank you so much :)

@rushilg13
Copy link

For anyone interested, I found the solution:

Open your Anaconda Prompt.
Activate your env (this step is optional if you dont work with envs)
type this: python -m ipykernel install --user
Start your jupyter notebook

This Worked for me! Thankssssss <3

@NeelmaniShrivastava
Copy link

This is a life saver. Thanks, guys

@yuskeaita
Copy link

yuskeaita commented Jun 21, 2021

The solution mentioned above did not work for me. Can anyone help me?
When I opened "Jupyter notebook" from Anaconda, it successfully opened. Then I clicked 'conda' button,
image
appeared.

(py3) C:\Users\Yusuke>jupyter notebook 
[W 19:57:34.081 NotebookApp] Collisions detected in C:\Users\Yusuke\.jupyter\jupyter_notebook_config.py and C:\Users\Yusuke\.jupyter\jupyter_notebook_config.json config files. C:\Users\Yusuke\.jupyter\jupyter_notebook_config.json has higher priority: {                                                                                                                  "NotebookApp": {                                                                                                          "kernel_spec_manager_class": "'environment_kernels.EnvironmentKernelSpecManager' ignored, using 'nb_conda_kernels.CondaKernelSpecManager'"                                                                                                    }                                                                                                                     }
[I 19:57:36.349 NotebookApp] Removing existing kernelspec in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-root-py
[I 19:57:36.417 NotebookApp] Installed kernelspec conda-root-py in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-root-py                                                                                                                
[I 19:57:36.424 NotebookApp] Removing existing kernelspec in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-env-py3-py
[I 19:57:36.471 NotebookApp] Installed kernelspec conda-env-py3-py in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-env-py3-py                                                                                                         
[I 19:57:36.483 NotebookApp] Removing existing kernelspec in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-env-py36_test-py                                                                                                             
[I 19:57:36.515 NotebookApp] Installed kernelspec conda-env-py36_test-py in C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\conda-env-py36_test-py    
[I 19:57:36.521 NotebookApp] [nb_conda_kernels] enabled, 3 kernels found  
[W 2021-06-21 19:57:38.673 LabApp] Config option `kernel_spec_manager_class` not recognized by `LabApp`. 
[W 2021-06-21 19:57:38.683 LabApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release. 
[W 2021-06-21 19:57:38.683 LabApp] 'kernel_spec_manager_class' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.                                         
[W 2021-06-21 19:57:38.686 LabApp] Config option `kernel_spec_manager_class` not recognized by `LabApp`.                
[I 2021-06-21 19:57:38.699 LabApp] JupyterLab extension loaded from C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\jupyterlab                                                                                                             
[I 2021-06-21 19:57:38.699 LabApp] JupyterLab application directory is C:\Users\Yusuke\Anaconda3\envs\py3\share\jupyter\lab                                                                                                                     [I 19:57:38.718 NotebookApp] [nb_conda] enabled                                                                         
[I 19:57:38.726 NotebookApp] Serving notebooks from local directory: C:\Users\Yusuke                                    
[I 19:57:38.726 NotebookApp] Jupyter Notebook 6.2.0 is running at:                                                      
[I 19:57:38.728 NotebookApp] http://localhost:8888/?token=557b6bcb4da2b72a866aa0818a902769b2eb241515203de9   
[I 19:57:38.729 NotebookApp]  or http://127.0.0.1:8888/?token=557b6bcb4da2b72a866aa0818a902769b2eb241515203de9          
[I 19:57:38.730 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).  
[C 19:57:38.841 NotebookApp]                                                                                                                                                                                                                        To access the notebook, open this file in a browser:                                                                        file:///C:/Users/Yusuke/AppData/Roaming/jupyter/runtime/nbserver-9228-open.html
Or copy and paste one of these URLs: 
http://localhost:8888/?token=557b6bcb4da2b72a866aa0818a902769b2eb241515203de9                                        or http://127.0.0.1:8888/?token=557b6bcb4da2b72a866aa0818a902769b2eb241515203de9
[E 19:57:42.988 NotebookApp] Uncaught exception GET /conda/environments?_=1624273061120 (::1) 
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/conda/environments?_=1624273061120', version='HTTP/1.1', remote_ip='::1')                                                                                         
Traceback (most recent call last):
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\tornado\web.py", line 1702, in _execute
result = method(*self.path_args, **self.path_kwargs)                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\tornado\web.py", line 3173, in wrapper                         
return method(self, *args, **kwargs)                                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\notebook\base\handlers.py", line 782, in wrapper               
return method(self, *args, **kwargs)
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\nb_conda\handlers.py", line 51, in get                         self.finish(json.dumps(self.env_manager.list_envs()))
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\nb_conda\envmanager.py", line 67, in list_envs
info = self.clean_conda_json(self._execute('conda info --json'))                                                      
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\nb_conda\envmanager.py", line 53, in _execute
output = check_output(cmdline)
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 411, in check_output
**kwargs).stdout
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 488, in run                       
with Popen(*popenargs, **kwargs) as process:    
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)                                                                                   
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)                                                              
FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。 (The system cannot find the file specified.)                                                
[W 19:57:43.110 NotebookApp] Unhandled error  
E 19:57:43.117 NotebookApp] {                                                                                                "
Host": "localhost:8888",                                                                                               "
Connection": "keep-alive",                                                                                             
"Sec-Ch-Ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"91\", \"Chromium\";v=\"91\"",                           
 "Accept": "application/json, text/javascript, */*; q=0.01",                                                             
"X-Xsrftoken": "2|31626b86|4b9b22e809faaf9c202ef0efb066520e|1621811786",                                                
"X-Requested-With": "XMLHttpRequest",                                                                                   
"Sec-Ch-Ua-Mobile": "?0",                                                                                               
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",                                                                                                            
"Sec-Fetch-Site": "same-origin",                                                                                        
"Sec-Fetch-Mode": "cors",                                                                                               
"Sec-Fetch-Dest": "empty",                                                                                              
"Referer": "http://localhost:8888/tree",                                                                                
"Accept-Encoding": "gzip, deflate, br",                                                                                 
"Accept-Language": "ja,en;q=0.9,en-US;q=0.8",                                                                           
"Cookie": "_xsrf=2|31626b86|4b9b22e809faaf9c202ef0efb066520e|1621811786; username-localhost-8888=\"2|1:0|10:1624273060|23:username-localhost-8888|44:MTc5YzJkMTJhY2ExNDk0ZDhmZWRlZDgyNGVlMTlkYTI=|8e387ac882126f4cc64b15f191a59358762f02ee2e7d18bfe897504bdc6d4efc\""                                                                                                 }                                                                                                                   [E 19:57:43.117 NotebookApp] 500 GET /conda/environments?_=1624273061120 (::1) 163.420000ms referer=http://localhost:8888/tree                                                                                                                  
[E 19:57:43.140 NotebookApp] Uncaught exception GET /conda/packages/available?_=1624273061121 (::1)                         HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/conda/packages/available?_=1624273061121', version='HTTP/1.1', remote_ip='::1')                                                                                   Traceback (most recent call last):                                                                                        File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\tornado\web.py", line 1702, in _execute                        
result = method(*self.path_args, **self.path_kwargs)                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\tornado\web.py", line 3173, in wrapper                         
return method(self, *args, **kwargs)                                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\notebook\base\handlers.py", line 782, in wrapper              
 return method(self, *args, **kwargs)                                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\nb_conda\handlers.py", line 230, in get                        
data = searcher.list_available(self)                                                                                  
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\site-packages\nb_conda\handlers.py", line 213, in list_available             bufsize=4096)                                                                                                         
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 800, in __init__                                        
restore_signals, start_new_session)                                                                                   
File "C:\Users\Yusuke\Anaconda3\envs\py3\lib\subprocess.py", line 1207, in _execute_child                                 
startupinfo)                                                                                                        
FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。(The system cannot find the file specified.) 
[W 19:57:43.152 NotebookApp] Unhandled error
[E 19:57:43.155 NotebookApp] { 
"Host": "localhost:8888",
"Connection": "keep-alive",
"Sec-Ch-Ua": "\" Not;A Brand\";v=\"99\", \"Google Chrome\";v=\"91\", \"Chromium\";v=\"91\"", 
"Accept": "application/json, text/javascript, */*; q=0.01",
"X-Xsrftoken": "2|31626b86|4b9b22e809faaf9c202ef0efb066520e|1621811786", 
"X-Requested-With": "XMLHttpRequest", 
"Sec-Ch-Ua-Mobile": "?0",                                                                                               
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",                                                                                                           
"Sec-Fetch-Site": "same-origin",                                                                                        
"Sec-Fetch-Mode": "cors",                                                                                               
"Sec-Fetch-Dest": "empty",                                                                                              
"Referer": "http://localhost:8888/tree",                                                                                
"Accept-Encoding": "gzip, deflate, br",                                                                                 
"Accept-Language": "ja,en;q=0.9,en-US;q=0.8",                                                                           
"Cookie": "_xsrf=2|31626b86|4b9b22e809faaf9c202ef0efb066520e|1621811786; username-localhost-8888=\"2|1:0|10:1624273060|23:username-localhost-8888|44:MTc5YzJkMTJhY2ExNDk0ZDhmZWRlZDgyNGVlMTlkYTI=|8e387ac882126f4cc64b15f191a59358762f02ee2e7d18bfe897504bdc6d4efc\""
                                                                                                }                                                                                                                   [E 19:57:43.155 NotebookApp] 500 GET /conda/packages/available?_=1624273061121 (::1) 31.960000ms referer=http://localhost:8888/tree  

@yuskeaita
Copy link

yuskeaita commented Jun 21, 2021

I also changed 'jupyter_config.json' file.

{
"JupyterApp": {
"kernel_spec_manager_class": "nb_conda_kernels.CondaKernelSpecManager"
},
"CondaKernelSpecManager": {
"kernelspec_path": "--user"
}
}

@yuskeaita
Copy link

yuskeaita commented Jun 21, 2021

These are the versions I have.

  • jupyter core : 4.7.1
  • jupyter-notebook : 6.2.0
  • qtconsole : 5.0.3
  • ipython : 7.21.0
  • ipykernel : 5.3.4
  • jupyter client : 6.1.7
  • jupyter lab : 3.0.14
  • nbconvert : 6.0.7
  • ipywidgets : 7.6.3
  • nbformat : 5.1.2
  • traitlets : 5.0.5

@yuskeaita
Copy link

And I created 'jupyter_notebook_config.py' and added the sentence below.

#c.EnvironmentKernelSpecManager.conda_env_dirs=['C:\Users\Yusuke\AppData\Roaming\jupyter\kernels\python3']

@kevin-bates
Copy link
Member

Hi @yuskeaita. Your issue should probably be opened in the nb_conda_kernels repository. My understanding is that NB Conda Kernels' kernel spec manager implementation essentially mirrors existing kernel spec files (kernel.json) for each conda env and uses a different command (nb_conda_kernels.runner) to launch the kernel (presumably to activate the target env). I suspect that one of your environments is missing nb_conda_kernels.runner and that's why you get the 'File not found' exception during your kernel's launch. The folks in nb_conda_kernels should be able to get you going.

Also, note that you're using Lab >= 3.0 which means you're using Jupyter Server as your notebook server. So should this turn out to be a general server issue, any follow-up should occur in the jupyter_server repository. Thanks.

@yuskeaita
Copy link

Oh, Thanks kevin-bates! I'll do that! I appreciate it.

@ZuZuOnline
Copy link

I found a solution to solve this problem. follow the steps bellow:
go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.
{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
launch jupyter notebook. Everything is fine now.

It Worked. Thanks..!!

it works for me. Thanks

@hammaadworks
Copy link

I found a solution to solve this problem. follow the steps bellow:

go to directory: /python/share/jupyter/kernels/
open the file "kernel.json", and set the "argv": the python path for example.

{
"argv": [
"C:\Anaconda3\python.exe",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}

launch jupyter notebook. Everything is fine now.

Thanks, worked for me👍🏻

@schmidtijoe
Copy link

FYI:
i am on windows and using jetbrains IDE: in (usually) C:\user\AppData\Roaming\jupyter\kernels\
there might be other configurations created by eg. pycharm, check all of them and use the above mentioned fix. It somehow crashed for me after conda create and all above mentioned files seemed fine but there was one extra in a pycharm created directory which still pointed to an old and gone env.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests