Atom: Error running Hydrogen, python.exe can't be found

Viewed 396

I've recently run a complete reinstallation of Anaconda, as well as Atom with Script and Hydrogen. Before the reinstallation everything ran fine. Now, when trying to execute a Python script line using Ctrl+Enter I'm getting the following error:

'C:\Users\vestland\AppData\Local\Programs\Python\Python37-32\python.exe' is not recognized as an internal or external command, operable program or batch file.

error

And that's no wonder, because there is no python.exe in that folder. It's in 'C:\Users\vestland\AppData\Local\Programs\Python\Python37-32\SCRIPT\python.exe'. How can I change that reference within Atom?

I've tried adding 'C:\Users\vestland\AppData\Local\Programs\Python\Python37-32\SCRIPT\python.exe' to PATH but to no avail.

I've also tried editing the Hydrogen kernel.json file as per the suggestion here to:

{
 "display_name": "MyPython3",
 "argv": [
  "C:\\Users\\vestland\\AppData\\Local\\Programs\\Python\\Python37-32\\scripts\\python.exe",
  "-m",
  "ipykernel",
  "-f",
  "{connection_file}"
 ],
 "language": "python"
}

Thank you for any suggestions!

Edit:

Running Python using ctrl+shift+b works just fine! But that's a command for the Script package and not Hydrogen.

3 Answers

If you python location is C:\Users\vestland\AppData\Local\Programs\Python\Python37-32\SCRIPT\python.exe the kernel.json file has an additional s in scripts, the correct version would be:

{
 "display_name": "MyPython3",
 "argv": [
  "C:\\Users\\vestland\\AppData\\Local\\Programs\\Python\\Python37-3\\SCRIPT\\python.exe",
  "-m",
  "ipykernel",
  "-f",
  "{connection_file}"
 ],
 "language": "python"
}

But I would suggest that kernel.json uses the python default from the PATH only you are not planning to use any virtual environment.

{
 "display_name": "MyPython3",
 "argv": [
  "python.exe",
  "-m",
  "ipykernel",
  "-f",
  "{connection_file}"
 ],
 "language": "python"
}

If that doesn't work, check if the system kernel folder is used instead, you can find it in %PROGRAMDATA%\jupyter\kernels

I've tried adding 'C:\Users\\AppData\Local\Programs\Python\Python37-32\SCRIPT\python.exe' to PATH but to no avail.

Try adding 'C:\Users\\AppData\Local\Programs\Python\Python37-32\SCRIPT\' to PATH instead and restart Atom. (In other words add the folder containing the exe instead of the path\filename.)

Solution: Remove lurking kernels!

For some unknown reason, after countless reinstallations of Python, Atom, Script, Hydrogen and various attempts of

python -m pip install ipykernel
python -m ipykernel install --user

... I found a rogue kernel lurking in the depths of

C:\Users\vestland\AppData\Roaming\jupyter\kernels\python3

As you can see from the screenshot, it's been there for quite some time despite my countless efforts to reset the entire system:

enter image description here

So I just deleted it, fired up Atom using a command prompt and atom ., and now everything runs just fine using keyboard shortcuts for Hydrogen:

enter image description here

The details:

Running C:\>jupyter kernelspec list --json returned:

{
  "kernelspecs": {
    "1450be76-28c2-4c3d-a5f0-c56b3ef13d75": {
      "resource_dir": "C:\\Users\vestland\AppData\\Roaming\\jupyter\\kernels\\1450be76-28c2-4c3d-a5f0-c56b3ef13d75",
      "spec": {
        "argv": [
          "C:\\Users\\vestland\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe",
        [...]
      }
    },
    "python3": {
      "resource_dir": "C:\\Users\vestlad\AppData\\Roaming\\jupyter\\kernels\\python3",
      "spec": {
        "argv": [
          "C:\\Users\\vestland\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe",
         [...]
      }
    }
  }
}

And that turned out to be the culprit of the problem and why I could not rid myself of the C:\\Users\\vestland\\AppData\\Local\\Programs\\Python\\Python37-32\\python.exe error message. Somehow, Hydrogen picked up on that directory each time I tried to do something with Hydrogen and Atom.

Running jupyter kernelspec list showed me the locations of these kernels:

Available kernels:
  1450be76-28c2-4c3d-a5f0-c56b3ef13d75    C:\Users\vestland\AppData\Roaming\jupyter\kernels\1450be76-28c2-4c3d-a5f0-c56b3ef13d75
  python3                                 C:\Users\vestland\AppData\Roaming\jupyter\kernels\python3

A simple deletion of the former kernel solved all problems. For now...

Related