Holcombe:PythonIDEs: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
Running python interactively from the Terminal alone is frustrating because you can't use arrow keys for history, no auto-complete, etc. Also there is no text editor linked to it. You will probably want to use an IDE that has built in text editor  
Running python interactively from the Terminal alone is frustrating because you can't use arrow keys for history, no auto-complete, etc. Also there is no text editor linked to it. You will probably want to use an IDE that has built in text editor  
From any interpreter, execute a script using execfile('test.py')
== IPython ==
Doesn't have a text editor, but  gives you a command line that's better with command history, tab completion, other goodies
I updated to IPython0.1 12Nov2009 on forest-laptop by downloading the .egg file, putting it in /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages, and from terminal there "sudo easy_install ipython-0.10-py2.5.egg"
In my .profile file in my home directory I added the following lines:
<code>
PYTHONSTARTUP="pythonstartup.py"
export PYTHONSTARTUP
PYTHONPATH="~/Library/IPython"
export PYTHONPATH
</code>
I then created a pythonstartup.py file so that IPython automatically run when start python. IPython has trouble finding readline, hence the second line:
<code>
import sys
sys.path.insert(0,'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/readline-2.5.1-py2.5- macosx-10.5-i386.egg')
import IPython
sys.argv = [sys.argv[0], '-pylab'] #needed to allow interactive plotting
IPython.Shell.start().mainloop()
</code>
To quickly open code from IPython and edit it, I added this to my .profile:
<code>
alias edit='open -a TextWrangler'
EDITOR="edit -w" #w is special flag allowing TextWrangler to be used, see man page for edit
export EDITOR
</code>
Also customize coloring and such by editing this file
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ipython-0.9.1-py2.5.egg/IPython/UserConfig/ipy_user_conf.py
== Dr. Python ==
== Dr. Python ==
Dr. Python is good because it checks indentation. Instead of using {} to delimit code blocks, it uses indentation like so:
Dr. Python is good because it checks indentation. Instead of using {} to delimit code blocks, it uses indentation like so:
Line 13: Line 50:
   asdf
   asdf
   asdf
   asdf
</code>
== IPython ==
Doesn't have a text editor, but at least gives you a command line that's better with command history, tab completion,
In my .profile I added the following lines:
<code>
PYTHONSTARTUP="pythonstartup.py"
export PYTHONSTARTUP
PYTHONPATH=~/Library/IPython
export $PYTHONPATH
</code>
I then created a pythonstartup.py file so that IPython automatically run when start python. IPython has trouble finding readline, hence the second line:
<code>
import sys
sys.path.insert(0,'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/readline-2.5.1-py2.5-macosx-10.5-i386.egg')
import IPython
IPython.Shell.start().mainloop()
</code>
</code>

Latest revision as of 17:47, 15 March 2010

Running python interactively from the Terminal alone is frustrating because you can't use arrow keys for history, no auto-complete, etc. Also there is no text editor linked to it. You will probably want to use an IDE that has built in text editor

From any interpreter, execute a script using execfile('test.py')

IPython

Doesn't have a text editor, but gives you a command line that's better with command history, tab completion, other goodies

I updated to IPython0.1 12Nov2009 on forest-laptop by downloading the .egg file, putting it in /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages, and from terminal there "sudo easy_install ipython-0.10-py2.5.egg"

In my .profile file in my home directory I added the following lines:

PYTHONSTARTUP="pythonstartup.py"
export PYTHONSTARTUP
PYTHONPATH="~/Library/IPython"
export PYTHONPATH

I then created a pythonstartup.py file so that IPython automatically run when start python. IPython has trouble finding readline, hence the second line:

import sys
sys.path.insert(0,'/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/readline-2.5.1-py2.5- macosx-10.5-i386.egg')
import IPython 
sys.argv = [sys.argv[0], '-pylab'] #needed to allow interactive plotting
IPython.Shell.start().mainloop()

To quickly open code from IPython and edit it, I added this to my .profile:

alias edit='open -a TextWrangler'
EDITOR="edit -w" #w is special flag allowing TextWrangler to be used, see man page for edit
export EDITOR

Also customize coloring and such by editing this file /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ipython-0.9.1-py2.5.egg/IPython/UserConfig/ipy_user_conf.py

Dr. Python

Dr. Python is good because it checks indentation. Instead of using {} to delimit code blocks, it uses indentation like so: if X

 asdf
 asdf

dddd ---Each line needs to be offset by the same number of spaces/tabs. Dr. Python checks to make sure this is true so you're not tripped up by invisible characters like tabs masquerading as spaces

if X

 asdf
 asdf