Question or problem about Python programming:
Is there a GUI for IPython that allows me to open/run/edit Python files? My way of working in IDLE is to have two windows open: the shell and a .py file. I edit the .py file, run it, and interact with the results in the shell.
Is it possible to use IPython like this? Or is there an alternative way of working?
How to solve the problem:
When I’m working with python, I usually have two terminal windows open – one with IPython, and the other with a fairly customized Vim.
Two good resources:
Though it sounds like what you want is IPython’s magic function
An example of what you can do:
In : %ed IPython will make a temporary file named: c:\docume~1\wjwe312\locals~1\temp\ipython_edit_ar8veu.py
In the file I put:
x = "Hello World" print 3
After saving and quitting the file:
Editing... done. Executing edited code... 3 Out: "x = 'Hello world'\nprint 3\n" In : x Out: 'Hello world'
You can define functions or anything else – just remember that the contents of the file will be executed when you close it.
Another similar workflow is to
cd to the directory containing your Python script that you’re editing with your favorite editor. Then you can
%run the script from within IPython and you’ll have access to everything defined in the file. For instance, if you have the following in the file
test.py in your
class Tester(object): def __init__(self): print "hi" def knightme(name): print "Hello, Sir ", name
Then you can do the following:
In : cd /home/myself /home/myself In : %run test.py #
autocomplete also works In : knightme('John') Hello, Sir John In : t = Tester() Hi
Either a mix or one of those workflows should give you something very similar to the way you’re used to working in IDLE.
Spyder, previously known as SPyderlib / Spyder2
Pretty lightweight, fast and support almost all features you will ever need to work with a python project. It can edit and run .py files in an embedded IPython instance and then interact with them, set breakpoints, etc.
Try Spyder, I have spent all day trying to find an IDE which has the functionality of ipython and Spyder just kicks it out of the park..
Autocomplete is top notch right from install, no config files and all that crap, and it has an Ipython terminal in the corner for you to instantly run your code.
big thumbs up
Take a look at DreamPie. Might be what you are looking for.
Personally, I like PyScripter. Unfortunately, it only works on Windows, but also runs perfectly in Wine.
The latest version of IdleX supports IPython within IDLE, as well as the %edit magic. You can run your files from the IDLE editor within the IPython shell many ways, either by F5 (run everything), F9 (run a selection), or Ctrl+Enter (run a subcode).
If you like the work-flow under
Matlab, then you probably should try the following two:
1, Try the combination of
Edit python files in
Spydercan reload the file automatically)
Run the code in
Spyder(in the same interpreter, which is important for me):
F9to run the current file
Ctrl+F9to run the selected block
conque-shell. (on google code)
Open your preferred
then visual select some
F9to paste and run it in the
Python interpreter buffer.
Note: a few more:
:ConqueTermVSplit rlwrap python
If your interpretor misses
readline, you can use
You might like PySlices…
It’s kind of a shell/editor hybrid that lets you save your session as special (barely) modified python files called .pyslice files.
It’s now part of wxPython, so just install that (v2.8.11 or later) and run “python -m wx.py.PySlices” on the command line to launch it.
That said, I still end up using an external editor for scripts (geany).
sudo apt-get install ipython
Once you are done with installing ipython.
Start ipython from terminal (just hit
ipython in the ternminal)
ravi.py file all you need to do is
I want to suggest excellent plugin for vim that makes two-way integration between Vim and IPython: vim-ipython.
From project page on http://github.com/ivanov/vim-ipython:
Using this plugin, you can send lines or whole files for IPython to execute, and also get back object introspection and word completions in Vim, like what you get with: object? and object. in IPython.
This plugin has one big limitation: it doesn’t support python 3 (it’s planned).