views:

496

answers:

9

I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.

What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.

I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.

EDIT: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. :) I'd recommend Visual Studio, NUnit, SQL Server, etc.

+1  A: 

Python (duh), setuptools or pip, virtualenv, and an editor. I suggest geany, but that's just me. And of course, any other Python modules you'll need.

Ignacio Vazquez-Abrams
+8  A: 

Your system already has Python on it. Use the text editor or IDE of your choice; I like vim.

I can't tell you what third-party modules you need without knowing what kind of development you will be doing. Use apt as much as you can to get the libraries.


To speak to your edit:

This isn't minimalistic, like handing a .NET newbie notepad and a compiler: a decent text editor and the stdlib are all you really need to start out. You will likely need third-party libraries to develop whatever kind of applications you are writing, but I cannot think of any third-party modules all Python programmers will really need or want.

Unlke the .NET/Windows programming world, there is no one set of dev tools that stands above all others. Different people use different editors a whole lot. In Python, a module namespace is fully within a single file and project organization is based on the filesystem, so people do not lean on their IDEs as hard. Different projects use different version control software, which has been booming with new faces recently. Most of these are better than TFS and all are 1000 times better than SourceSafe.

When I want an interactive session, I use the vanilla Python interpreter. Various more fancy interpreters exist: bpython, ipython, IDLE. bpython is the least fancy of these and is supposed to be good about not doing weird stuff. ipython and IDLE can lead to strange bugs where code that works in them doens't work in normal Python and vice-versa; I've seen this first hand with IDLE.

For some of the tools you asked about and some others

  • In .NET you would use NUnit. In Python, use the stdlib unittest module. There are various third-party extensions and test runners, but unittest should suit you okay.
    • If you really want to look into something beyond this, get unittest2, a backport of the 2.7 version of unittest. It has incorporated all the best things from the third-party tools and is really neat.
  • In .NET you would use SQL Server. In Python, you may use PostgreSQL, MySQL, sqlite, or some other database. Python specifies a unified API for databases and porting from one to another typically goes pretty smoothly. sqlite is in the stdlib.
    • There are various Object Relational Models to make using databases more abstracted. SQLAlchemy is the most notable of these.
  • If you are doing network programming, get Twisted.
  • If you are doing numerical math, get numpy and scipy.
  • If you are doing web development, choose a framework. There are about 200000: Pylons, zope, Django, CherryPy, werkzeug...I won't bother starting an argument by recommending one. Most of these will happily work with various servers with a quick setting.
  • If you want to do GUI development, there are quite a few Python bindings. The stdlib ships with Tk bindings I would not bother with. There are wx bindings (wxpython), GTK+ bindings (pygtk), and two sets of Qt bindings. If you want to do native Windows GUI development, get IronPython and do it in .NET. There are win32 bindings, but they'll make you want to pull your hair out trying to use them directly.
Mike Graham
might want to add a note to `pip` to install 3rd party libraries.
Kimvais
+1: "Batteries Included". Must of what you need is already in the standard install.
S.Lott
Thanks for the additional info! I realize I may not *need* all the stuff you mentioned, but as a newcomer to the Python community, it's really helpful to know what tools are out there and commonly used.
Rob Sobers
@Rob Sobers: First, go here: http://docs.python.org/index.html. Under library it says "keep this under your pillow". Almost everything you'll ever need is already there, and already documented. The answer to this question *assumes* you've already looked there first.
S.Lott
+3  A: 

If you launch a terminal and type python you'll get an interpreter, where you can start trying stuff.

Just in case you haven't seen it, check out the book Dive Into Python, is free on-line. http://www.diveintopython.org/

Follow the examples in the book using the interpreter.

For storing your work you could use any editor; Vim or EMACS could be the most powerful, but also the most difficult to learn at first. If you want a more "traditional" IDE, you could try WingIDE. http://www.wingware.com/

After you start to get more comfortable with python you should try an enhanced interpreter; try ipython. http://ipython.scipy.org/moin/

When you start to develop a more serious project you'll need to get additional modules. Here you have two options; 1) Use your distribution tools to install additional modules; or 2) Download the modules you need directly from their sites and install them manually. You'll be responsible to upgrade them of course.

You'll have to decide for yourself which way to go. Personally I prefer to download and install additional modules manually.

Jorge Gajon
DIP targets 2.3 and 3.x, neither of which versions are ideal for a learner today; there have been fairly big changes between 2.3 and 2.6, and 3.1 isn't well-supported enough to build many useful programs with. It is also full of ugly examples and technically-incorrect claims. When someone is learning Python as their first language, I usually recommend How To Think Like a Computer Scientist http://tinyurl.com/thinkcspy2e If someone already knows to program well, for example if the OP is an advanced user of C#, the official tutorial http://docs.python.org/tut/ is usually enough to get them going
Mike Graham
+ for ipython. I want to make it my shell :)
Tom Willis
+4  A: 

Since I'm accustomed to Eclipse, I find Eclipse + PyDev convenient for Python. For quick computations, Idle is great.

I've used Python on Windows and on Ubuntu, and Linux is much cleaner.

FarmBoy
+1 for PyDev. It's a great IDE, and it's also nice to stay in a single IDE for other projects (e.g. Java and Perl).
bedwyr
BTW, instead of (or in addition to) IDLE you might want to check out DreamPie (http://dreampie.sourceforge.net/). I haven't used it much, but it looks interesting.
Javier Badia
+2  A: 

In order to reduce the chance of effecting/hosing the system install of python, I typically install virtualenv on the ubuntu python install. I then create a virtualenv in my home directory so that subsequent packages I install via pip or easy_install do not effect the system installation. And I add the bin from that virtualenv to my path via .bashrc

$ sudo apt-get install python-virtualenv
$ virtualenv --no-site-packages ~/local
$ PATH=~/local/bin:$PATH #<----- add this to .bashrc to make it permanent
$ easy_install virtualenv #<--- so that project environments are based off your local environment rather than the system, probably not necessary

Install your favorite editor, I like emacs + rope, but editors are a personal preference and there are plenty of choices.

When I start a new project/idea I create a new virtual environment for that project, so that I don't effect dependencies anywhere else. Since I would hate for some of my projects to break due to an upgrade of a library both that project and the new one depends on.

~/projects $ virtualenv --no-site-packages my_new_project.env
~/projects/my_new_project.env $ source bin/activate
(my_new_project.env)~/projects/my_new_project.env $ easy_install paste ipython #whatever else I think I need
(my_new_project.env)~/projects/my_new_project.env $ emacs ./ & # start hacking

When creating a new package...in order to have something that will be easy_installable/pippable use paster create

(my_new_project.env)~/projects/my_new_project.env$ paster create new_package
(my_new_project.env)~/projects/my_new_project.env/new_package$ python setup.py develop new_package

That's the common stuff as far as I can think of it. Everything else would be editor/version control tool specific

Tom Willis
+1  A: 

If you're just starting out with Python, I'd actually argue against bringing in the complexity of virtualenv (which I think can be pretty overwhelming), at least until you've got a firm grasp of Python basics (especially regarding library/dependency management).

If you're using Ubuntu and the Gnome desktop environment, gedit is the default (gui) text editor, and has great support for Python built in. So my recommendation is to start with the pre-installed Python and gedit (which is pretty extensible on its own).

Will McCutchen
A: 

You would probably like to give NetBeans Python IDE a shot. You can choose to use either Windows/Linux.

Amit
A: 

Database: sqlite (inbuilt). You might want SQLAlchemy though.

GUI: tcl is inbuilt, but wxPython or pyQt are recommended.

IDE: I use idle (inbuilt) on windows, TextMate on Mac, but you might like PyDev. I've also heard good things about ulipad.

Numerics: numpy.

Fast inline code: lots of options. I like boost weave (part of scipy), but you could look into ctypes (to use dlls), Cython, etc.

Web server: too many options. Django (plus Apache) is the biggest.

Unit testing: inbuilt.

Pyparsing, just because.

BeautifulSoup (or another good HTML parser).

hg, git, or some other nice VC.

Trac, or another bug system.

Oh, and StackOverflow if you have any questions.

wisty
+1  A: 

You don't need much. Python comes with "Batteries Included."

Visual Studio == IDLE. You already have it. If you want more IDE-like environment, install Komodo Edit.

NUnit == unittest. You already have it in the standard library.

SQL Server == sqlite. You already have it in the standard library.

Stop wasting time getting everything ready. It's already there in the basic Python installation.

Get to work.

Linux, BTW, is primarily a development environment. It was designed and built by developers for developers. Windows is an end-user environment which has to be supplemented for development.

Linux was originally focused on developers. All the tools you need are either already there or are part of simple yum or RPM installs.

S.Lott