Can't run python on atom but can on cmd prompt

Python works on cmd prompt but doesn’t work on here. I have just started coding a few weeks ago and just want to learn python. This is the error msg: “Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.”

What follows is just one way I have evolved for running Python … there are multiple ways described in this forum …

  1. Install process-palette

  2. Either edit process-palette settings (which can be tricky on first use) or edit manually the file $HOME/.atom/process-palette.json using the following snippet as guide:

    {
      "namespace": "process-palette",
      "action": "run-python",
      "command": "python3 -u  {fileAbsPath}",
      "arguments": [],
      "cwd": "~/anaconda3/bin/python",
      "inputDialogs": [],
      "env": {},
      "keystroke": null,
      "stream": true,
      "outputTarget": "panel",
      "outputBufferSize": 80000,
      "maxCompleted": 3,
      "autoShowOutput": true,
      "autoHideOutput": false,
      "scrollLockEnabled": false,
      "singular": false,
      "promptToSave": true,
      "saveOption": "none",
      "patterns": [
        "default"
      ],
      "successOutput": "{stdout}",
      "errorOutput": "{stdout}\n{stderr}",
      "fatalOutput": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}",
      "startMessage": null,
      "successMessage": "Executed : {fullCommand}",
      "errorMessage": "Executed : {fullCommand}\nReturned with code {exitStatus}\n{stderr}",
      "fatalMessage": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}",
      "menus": [
        "Run",
        "Python"
      ],

The above creates a menu item (Run) in your Atom topbar and if you have a python file in focus you just go to Run > Python > Run Python. Same approach for other languages … just different objects in json. Adjust settings to match your environment.

I can’t understand what you’re exactly saying, could you help?

Agreed that my posting script snippet above might be confusing for first time user.

Basically, for Atom to run Python (or other code) requires you to set up a connection between Atom environment and the Python environment (which you confirm works correctly).

Atom can use a number of packages for this connection.

You can search “commands”

And read …

Script package documentation

Process Palette documentation

Now my personal preference is process-palette but there is no reason why you should not try other packages.

In process-palette a number of variables can be passed outside Atom to your local python environment.

One is {fileAbsPath} which is the absolute path to the python file open in Atom. Then it becomes a process of just calling python (2 or 3) with {fileAbsPath} as variable. You can see this in line 3 in above json snippet:

 "command": "python3 -u  {fileAbsPath}",

My installation of Python is in anaconda3 and again you see this in above json snippet:

      "cwd": "~/anaconda3/bin/python",

but yours might be elsewhere. You need the path to your Python binary (Python2 or Python3).

process-palette settings does allow the command to be called from Atom menu bar rather than hot keys but that is your choice, i prefer using menu bar (Run Python) since hot keys might conflict with other hot keys in use by other packages (although keyboard-resolver helps in resolving such conflicts)

SUMMARY

  • Ignore the suggested snippet in previous post.

  • Read the documentation on script and process-palette and decide which you prefer to try (both work).

  • Use the Atom Settings > Packages GUI to set up your configuration to link your Atom files to executable Python.

======================================

Later Added Notes

I saw this video tutorial today.

It describes setting up script package rather than process-palette but same principles apply.