Sublime Forum

Run Python and Keep Python Command Line Open After

#1

Hello I am trying to move from Notepad++ to Sublime. I had a shortcut set up that would go to C:\Python26\python.exe -i "$(FULL_CURRENT_PATH)". That runs my file and then leaves me sitting in python which I always found helpful as I could try new code readily on top of my existing.

Is there a similar feature in Sublime that I am missing? Build is close, but the python command line doesn’t stay open

0 Likes

#2

In order to do something like this in Sublime, you need to use a plugin such as SublimeREPL. The build results pane doesn’t accept user input, so you can only use it to run non-interactive programs.

2 Likes

#3

Thanks. I got it installed but it seems buggy? Occasionally when I hit ctrl+, f it will say REPL Python is not available, even though it is open. The rest of the time it does nothing. What am I missing? I copied all of the settings from Default to User

0 Likes

#4

I must admit that I don’t actually use that plugin; I’m primarily a C developer so I’m not used to that kind of environment in my usual development workflow. As a result I can’t say offhand why it might not be working. There may be other similar plugins that perform a similar task, although this one is the one that seems to be the most recommended (both by it’s popularity on PackageControl and when this question has come up in the past).

It’s also a possibility to create/override the default Python build system to do something (probably) similar to what you were doing in Notepad++. Instead of executing python directly to run the script the build system would need to first open a new terminal window and then execute Python inside of it.

A past thread on how to accomplish this:

For reference, that forum post was referenced recently by someone asking how to accomplish this using Mac OS X (linked here in case someone finds this thread in future while trying to find a similar answer):

For the particular case of Windows, the first thread links to a package called Send to Shell which may be a better fit for what you’re trying to do if the REPL is not working as you want it too.

3 Likes

#5

I am not sure what happened, but I just came back to post the REPL seems to be working now for me. Maybe I got messed up with the short cuts as they are a bit odd - CTRL+, release, then the letter such as f.

Thanks

0 Likes

#6

You don’t need to do this. User’s settings are just here to overwrite the defaults.

Are you on window? Considering yes:

press window+r, type cmd and hit enter

type python. If you have a message saying that it is an unknown command, then you have to option:

  • add python to your path
  • specify to sublimeREPL where is python

For both of them, you need to find a file called python.exe, which is this one: C:\Python26\python.exe for you I understand.

add python to your path

  1. Open control panel -> system and security -> system
  2. On the left, click on advanced system settings
  3. Environment variable
  4. edit the Path variable: add a ;C:/python26/python.exe (make sure there is semi colon between each path)

Matt

1 Like

#7

Try to llok here enter link description here , not only this article i mean, may help u. Guys gave me a hand couple times while I was starting my own project.

0 Likes