TmSmth
TmSmth

Reputation: 452

iPython automatically at launch in Visual Studio Code on Os X

I would like that iPython run automatically when I launch VSC instead of typing ipython and press enter in the terminal. The answer here How to set ipython/jupyter as the default python terminal for vscode? doesn't work as it is for windows but it shouldn't be really different. Also, is there something similar to the 'Execute' button in Spyder instead of typing %run filename ? Thanks !

Upvotes: 2

Views: 1468

Answers (2)

user8408080
user8408080

Reputation: 2468

Sadly the nice workflow of spyder is not provided by any official extension at the moment (as far as I know).

But you can implement the basics easily on your own by writing an extension. Even with no experience in TypeScript you can quickly build an extension which starts an IPython console as soon as you open a python file. I also managed to execute a startup script which implements the runfile method. VS Code also allows keybindings for your functions, so that you can almost work like you can with spyder.

Spyder modified the IPython terminal quite a bit though, so it won't feel exactly the same. But after all, everything there is open source so you could implement it yourself, which is what I'm trying to do in my free time.

Upvotes: 2

R Chiodo
R Chiodo

Reputation: 554

I presume you mean you want to run the "Python Interactive Window" and not just an iPython console on startup

There is currently no way to run it on startup. At least no way without writing another extension that would run a command when opening a workspace. It would be simple for us to add one though. Probably a workspace setting. Can you log an issue here: https://github.com/Microsoft/vscode-python/issues/new

For you second question, 'Execute' in spyder, we have 'Run Current File in Python Interactive Window'. This works on any python file. You can get to it through the context menu on a file or through the command palette.

Upvotes: 2

Related Questions