Atom-script: Add a way to run python 3 without having to change run options every time

Created on 25 Oct 2017  路  6Comments  路  Source: atom-community/atom-script

I've been researching it for a while. Every time every few months that I want to run python 3 I end up googling and scrolling through the same pages. But over the time I've always had this issues with script. Could you please make it easier.
Now every time I have to run python 3 I have to press cmd-shift-i and type python3 for "command" option.
I would like to be able to just press cmd-i and get my code running. I'm sure I'm not the only one who would like that

Most helpful comment

We can set any python environment like this:
Go to .Atom/packages/script/lib/grammars/python.coffee,
Then replace python by python3 or /usr/local/bin/python3 or any path you have python installed.

For me, I had installed python using the Canopy Enthought, and this worked for me:

exports.Python =
  'Selection Based':
    command: '/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python'
    args: (context) -> ['-u', '-c', context.getCode()]

  'File Based':
    command: '/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python'
    args: ({filepath}) -> ['-u', filepath]

exports.MagicPython = exports.Python

exports.Sage =
  'Selection Based':
    command: 'sage'
    args: (context) -> ['-c', context.getCode()]

  'File Based':
    command: 'sage'
    args: ({filepath}) -> [filepath]

To check you can run this commands:

import sys

print(sys.executable)
print(sys.version)

I got following output:

/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python
3.5.2 |Enthought, Inc. (x86_64)| (default, Mar  2 2017, 08:29:05) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

All 6 comments

I share the same pain as @stwykd . It would be great to be able to Run Python3 without having to mess with configurations everytime I open Atom. Currently, I am using a diff. profile to run Python3 but that too is a couple of keystrokes away. If making Python 3 default is troublesome then pls add a feature to select a default profile so that users can decide only once and be done with it.

Thanks.

I switched to atom-runner over this one issue. Script is great in general, but this is a really basic change that for some reason the builders won't make, despite multiple issue threads about it over several years. It's a shame, but it is what it is.

We can set any python environment like this:
Go to .Atom/packages/script/lib/grammars/python.coffee,
Then replace python by python3 or /usr/local/bin/python3 or any path you have python installed.

For me, I had installed python using the Canopy Enthought, and this worked for me:

exports.Python =
  'Selection Based':
    command: '/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python'
    args: (context) -> ['-u', '-c', context.getCode()]

  'File Based':
    command: '/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python'
    args: ({filepath}) -> ['-u', filepath]

exports.MagicPython = exports.Python

exports.Sage =
  'Selection Based':
    command: 'sage'
    args: (context) -> ['-c', context.getCode()]

  'File Based':
    command: 'sage'
    args: ({filepath}) -> [filepath]

To check you can run this commands:

import sys

print(sys.executable)
print(sys.version)

I got following output:

/Users/poudel/Library/Enthought/Canopy/edm/envs/User/bin/python
3.5.2 |Enthought, Inc. (x86_64)| (default, Mar  2 2017, 08:29:05) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]

@bhishanpdl Thanks for the solution! This solves the problem.

@bhishanpdl thanks for this solution, it works great. They should make this an option.

My understanding is that this setting won't persist once script updates, but I suppose this may be the most frictionless way. Can just do it again when needed, as the updates seem pretty infrequent.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mblarsen picture mblarsen  路  6Comments

ld000 picture ld000  路  6Comments

chenkangcrack picture chenkangcrack  路  5Comments

wookiist picture wookiist  路  3Comments

STRAYKR picture STRAYKR  路  7Comments