Setting up a Python web development environment on OS X

I'm running Mac OS X Leopard and wanted to know what the easy way to setup a web development environment to use Python, MySQL, Apache on my machine which would allow me to develop on my Mac and then easily move it to a host in the future.

I've been trying to get mod_wsgi installed and configured to work with Django and have a headache now. Are there any web hosts that currently use mod_wsgi besides Google, so I could just develop there?


Asked by: Jared195 | Posted: 06-10-2021






Answer 1

FWIW, we've found virtualenv [http://pypi.python.org/pypi/virtualenv] to be an invaluable part of our dev setup. We typically work on multiple projects that use different versions of Python libraries etc. It's very difficult to do this on one machine without some way to provide a localized, customized Python environment, as virtualenv does.

Answered by: Alford268 | Posted: 07-11-2021



Answer 2

Most Python applications are moving away from mod_python. It can vary by framework or provider, but most development effort is going into mod_wsgi.

Using the WSGI standard will make your Python application server agnostic, and allow for other nice additions like WSGI middleware. Other providers may only provide CGI (which won't scale well performance wise), or FastCGI.

Answered by: Ada515 | Posted: 07-11-2021



Answer 3

I've worked with Django using only the included server in the manager.py script and have not had any trouble moving to a production environment.

If you put your application in a host that does the environment configuration for you (like WebFaction) you should not have problems moving from development to production.

Answered by: Julian325 | Posted: 07-11-2021



Answer 4

I run a Linux virtual machine on my Mac laptop. This allows me to keep my development environment and production environments perfectly in sync (and make snapshots for easy experimentation / rollback). I've found VMWare Fusion works the best, but there are free open source alternatives such as VirtualBox if you just want to get your feet wet.

I share the source folders from the guest Linux operating system on my Mac and edit them with the Mac source editor of my choosing (I use Eclipse / PyDev because the otherwise excellent TextMate doesn't deal well with Chinese text yet). I've documented the software setup for the guest Linux operating system here; it's optimized for serving multiple Django applications (including geodjango).

For extra added fun, you can edit your Mac's /etc/hosts file to make yourdomainname.com resolve to your guest Linux boxes internal IP address and have a simple way to work on / test multiple web projects online or offline without too much hassle.

Answered by: Rubie998 | Posted: 07-11-2021



Answer 5

What you're looking for is Mod_Python. It's an Apache-based interpreter for Python. Check it out here:

http://www.modpython.org/

Answered by: Alfred267 | Posted: 07-11-2021



Answer 6

Google App Engine has done it for you. Some limitations but it works great, and it gives you a path to hosting free.

Answered by: Julian295 | Posted: 07-11-2021



Answer 7

Of course Mac OS X, in recent versions, comes with Python and Apache. However you may want to have more flexibility in the versions you use, or you may not like the tweaks Apple has made to the way they are configured. A good way to get a more generic set of tools, including MySQL, is to install them anew. This will help your portability issues. The frameworks can be installed relatively easily with one of these open source package providers.

Answered by: Melissa527 | Posted: 07-11-2021



Answer 8

mod_wsgi is really, really simple.

Pyerweb is a really simple (~90 lines including comments/whitespace) WSGI-compliant routing-framework I wrote. Basically the WSGI API is just a function that gets passed environ, and wsgi_start_response, and it returns a string.

envrion is a dict with the request info, for example environ['PATH_INFO'] is the request URI)

wsgi_start_response which is a callable function which you execute to set the headers,:

wsgi_start_response(output_response, output_headers)

output_response is the string containing the HTTP status you wish to send (200 OK etc), and output_headers is a list-of-tuples containing your headers (for example, [("Content-type", "text/html")] would set the content-type)

Then the function returns a string containing your output.. That's all there is to it!

To run it, using spawning you can just do spawn scriptname.my_wsgi_function_nae and it will start listening on port 8080.

To use it via mod_wsgi, it's documentation is good, http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide and there is a django specific section

The up-side to using mod_wsgi is it's the standard for serving Python web-applications. I recently decided to play with Google App Engine, and was surprised when Pyerweb (which I linked to at the start of this answer) worked perfectly on it, completely unintentionally. I was even more impressed when I noticed Django applications run on it too.. Standardisation is a good thing!

Answered by: Clark995 | Posted: 07-11-2021



Answer 9

You may want to look into web2py. It includes an administration interface to develop via your browser. All you need in one package, including Python.

Answered by: Victoria470 | Posted: 07-11-2021



Answer 10

Check out WebFaction—although I don't use them (nor am I related to / profit from their business in any way). I've read over and over how great their service is and particularly how Django-friendly they are. There's a specific post in their forums about getting up and running with Django and mod_wsgi.

Like others before me in this thread, I highly recommend using Ian Bicking's virtualenv to isolate your development environment; there's a dedicated page in the mod_wsgi documentation for exactly that sort of setup.

I'd also urge you to check out pip, which is basically a smarter easy_install which knows about virtualenv. Pip does two really nice things for virtualenv-style development:

  • Knows how to install from source control (SVN, Git, etc...)
  • Knows how to "freeze" an existing development environement's requirements so that you can create that environment somewhere else—very very nice for multiple developers or deployment.

Answered by: David951 | Posted: 07-11-2021



Similar questions

python - Setting up orbited development environment on windows

I am developing a comet application using python orbited and django. But I don't know how to setup the development environment. Can any one please help me out? I looked at the documentations and tutorials... But I found them confusing... What I am looking is a walk-through kind of information.


Setting up a Python development environment on Windows

Yes, I've searched. So after spending about 4-5 hours struggling just to get Python files running, I recently stumbled over the solution to get it running through the environment variables like this: cmd -> python -> Python starts, yay yay Since it didn't work to do it through the command line and similar I had to do it manually through the Windows interface. Now that it's working, however I cannot open .py files w...


python - Setting Up Development Environment for Blender Project

I am trying to setup the development environment to run the source code of the Blender project. I have downloaded the source code from here I have installed Eclipse on my OS(Win-7) and set up environment for Python using PyDev. Now I need to ask how can I be able to load the Blender project. I mean to say which f...


development environment - switch versions of python

Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6...


setuptools - python egg development environment setup

I inherited a python project, which has been packaged as egg. Upon check out through SVN, I am seeing package content as: __init__.py scripts/ ptools/ setup.py ... Here, ptools/ hold the source of various modules. scripts/ is bunch of end-user tools that make use of modules provided by the "ptools". The package has been installed on this shared host environment through "easy_install", but ...


python - Setting up orbited development environment on windows

I am developing a comet application using python orbited and django. But I don't know how to setup the development environment. Can any one please help me out? I looked at the documentations and tutorials... But I found them confusing... What I am looking is a walk-through kind of information.


development environment - Should I use Python for a small CRM ? If not, then is there any other platform?

We have a new client who would like us to develop a custom CRM for their employees. The main features they would like are: Ability to save forms Send reminders to employees by email and text messages Basic charting capabilities Automatic backup online So as we see, saving data, and then reminding the employees are the most important functions of this CRM. ...


Setting up a Python development environment on Windows

Yes, I've searched. So after spending about 4-5 hours struggling just to get Python files running, I recently stumbled over the solution to get it running through the environment variables like this: cmd -> python -> Python starts, yay yay Since it didn't work to do it through the command line and similar I had to do it manually through the Windows interface. Now that it's working, however I cannot open .py files w...


development environment - Installing Python eggs under PyPy

How do I install Python egg under PyPy? During installation, PyPy created /usr/lib64/pypy-1.5/site-packages/ directory. So, I tried using easy_install with prefix set to this directory, however it complains that this is not a valid directory for eggs. Do I just copy eggs from /usr/lib/python2.7/site-packages, or is it as easy as using easy_install (with some changes in con...


python - Django - Mac development, environment hell

I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch. After just installing Python 2.7, and easy_install with setuptools for 2.7, this all in turn created ...


how do I launch IDLE, the development environment for Python, on Mac OS 10.7?

I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.


python - Change Facebook login redirect url depending on development or production environment?

Truthfully I didn't know how to title my question. I'm testing a facebook signup api with my app. I have my localhost:8000 url and my livesite url. What I want to do, is have it recognize which one I'm using (local vs live url) I thought this would work: <a href="https://www.facebook.com/plugins/registration.php?client_id=98493fakenumber239&redirect_uri=settings.SITE_URL+"social_login/facebo...


python - Serving static images in the development environment

I'm getting this broken image when I try to serve it from the media root. Kindly requesting you..not to show me the links for the docs or to previous questions. I've tried those things but I'm still getting this broken image. Models.py: class BasicModel(models.Model): name = models.CharField(max_length=200) dob = models.DateField() photo = models.ImageField(upload_to='sample') class Bas...


Windows Mobile development in Python

What is the best way to start developing Windows Mobile Professional applications in Python? Is there a reasonable SDK including an emulator? Is it even possible without doing excessive amount of underlaying Windows API calls for UI for instance?


How can I use Python for large scale development?

I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base? When you make incompatibility changes to the signature of a method, how do you find all the places where that method is being called. In C++/Java the compiler will find it for you, how do you do it in Python? When you make changes deep inside the code, how do you f...


Resources for TDD aimed at Python Web Development

Closed. This question does not meet Stack Overflow guid...


What should I be aware of when moving from asp.net to python for web development?

I'm thinking about converting an app from Asp.net to python. I would like to know: what are the key comparisons to be aware of when moving a asp.net app to python(insert framework)? Does python have user controls? Master pages?


Beginning Windows Mobile 6.1 Development With Python

I've wanted to get into Python development for awhile and most of my programming experience has been in .NET and no mobile development. I recently thought of a useful app to make for my windows mobile phone and thought this could be a great first Python project. I did a little research online and found PyCe which I think is what I would need to get started on the app? Can anyone with some experience in this are...


I need a beginners guide to setting up windows for python development

I currently work with .NET exclusively and would like to have a go at python. To this end I need to set up a python development environment. I guide to this would be handy. I guess I would be doing web development so will need a web server and probably a database. I also need pointers to popular ORM's, an MVC framework, and a testing library. One of my main criteria with all this is that I want to understand how it...


standards - What version of Python (2.4, 2.5, 2.6, 3.0) do you standardize on for production development efforts (and why)?

In our group we primarily do search engine architecture and content integration work and most of that code base is in Python. All our build tools and Python module dependencies are in source control so they can be checked out and the environment loaded for use regardless of os/platform, kinda similar to the approach


python - Django development add-ons


development environment - switch versions of python

Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6...


database - Agile Software Development in Python

Closed. This question needs to be more focused. It ...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top