OS X is a 'nix, so you'll probably fit right in. I have no problems with Python (specifically Django) dev on my MacBook (home) or MacBook Pro (work). I use MacPorts (including installing Python via port) to create a very Linux-ish command line environment, although lots of Python devs seem to prefer Homebrew. Os.name: This function gives the name of the operating system dependent module imported. Looking for Python with a different OS? Python for Windows, Linux/UNIX, Mac OS X, Other. Want to help test development versions of Python? Prereleases, Docker images. Looking for Python. Depending on how you use Python, you might want to update your installation at some point. Part of this process involves installing the GNU Compiler Collection (GCC) tools so that Python has access to the low-level resources it needs. The following steps get you started with installing a new version of Python on your Mac OS X system.
Even though Leopard ships with a fairly recent version of Python (2.5.1), there are several reasons one would want to use an alternative installation. For instance, Python 2.3.5 shipped with Tiger and was growing pretty long in the tooth by the time Leopard arrived; 2.3 was the default installation on Panther.
I've tried a few approaches to installing newer versions on the Mac: several years ago, I played around with Fink, then switched to MacPorts (formerly DarwinPorts). While either of these package managers make it very easy to install various software pacakages on the Mac, they each presented certain problems or limitations with respect to Python and the other web development packages I need.
My current preferred solution is to go with the MacPython distribution found on the Python website. There is also a great SIG (http://mail.python.org/mailman/listinfo/pythonmac-sig) for getting help.
From http://www.python.org/download/mac/:
Python comes pre-installed on Mac OS X, but due to Apple's release cycle, it's often one or even two years old. The overwhelming recommendation of the 'MacPython' community is to upgrade your Python by downloading and installing a newer version.
Listed below are the steps to setting up some of the most common Python packages used to for web development, particularly with respect to Django.
Basic assumptions

Mac OS X Leopard (10.5) - as of the date of this posting, I am on 10.5.3
Subversion - you can find an installer at http://subversion.tigris.org/
Install for all users of this computer mac. I use MySQL, so instructions for installing it and the necessary Python bindings (MySQLdb) are shown. If anyone has detailed instructions for Postgres installation, please send them to me at python [at] dakrauth.com
An installation directory to use for these steps. For instance, here's how I began (from a Terminal window,
bashshell):I use
~/python/site-packagesas an easy way of referencing packages that will change frequently or for creating a pseudo-virtual environment. More on this below.
Python 2.5.2

MacPython installation:
This installation will create the
site-packagesdirectory at:Additionally, your .profile file will be updated to place the above path at the front of you
$PATHenvironment variable. I usually remove this change, since the only thing I like to have my .profile file a source line to my .bashrc file. However, I ensure that/usr/local/binis place ahead/usr/binin my$PATHstring.Now I set up the ties to the aforementioned local site-packages directory:
MySQL
Lines 4, 5, and 6 below are a quick hack around an odd bug in the installer.
Add the preference pane to your System Preferences and start the server from the preference pane (I also prefer to select
Automatically Start MySQL Server on Startup):To setup a sample database to use with a Django project, here are the commands I issue from within the
mysqlshell:
MySQLdb
MySQLdb provides the Python bindings to interface with the database.
Edit the
site.cfgfile:Uncomment the line that begins
#mysql_config =Edit the path to point to
/usr/local/mysql/bin/mysql_config:
Complete the build and installation:
PIL
The Python Imaging Library adds image processing capabilities and supports many file formats. Probably on of the most common applications I use it for are resizing and cropping images, and generating thumbnail images. This installation seems to cause many people grief, particularly JPEG handling (which is an optional install that depends upon libjpeg).
freetype (optional) - a software font engine
libjpeg
PIL build
Checking for the following lines near the end of the output from the previous command:
Complet install and perform a last sanity check:
You should see a Preview window pop up with the picure of a woman wearing a hat.
Common Packages
IPython - An enhanced Python shell. You will want it - and be lost without it very quickly. Django will look for IPython when you run the
shellcommand extension.docutils
Markdown

Django
Installation of Django, using either Apache with mod_python, mod_wsgi, or FastCGI has been written about in numerous locations. However, here is my personal strategy for managing Django across various revisions:
First, I set up a directory to store the revisions of Django that I need across the sites I manage:
Next, I have two helper scripts I use to manage my revisions:
A revision 'getter' called
djget:Run
djgetto export your desired revisions (why not just to stick to one revision? I manage a few sites and not all are on the same revision. Also, I like to play around with the trunk tip on my local machine first before deploying it live).Example:
This will export the desired revision into a directory named for the revision number (
7728, in this case). It also generates HTML files from the reStructuredText documentation and moves those files into a newhtmldirectoryA revision switcher called
switch:Example:
This deletes existing symlinks to another revision and recreates them accordingly.
I add the
htmlsymlinked directory to my Bookmarks Bar in SafariFinally, I symlink the
djangosymlink in my local site-packages:

Install Django Mac
Optional packages
extensions- a repository for collecting global custom management extensions for the Django Framework. As a contributor to the repository, I would be remiss I neglected to mention it.- or -
An example of how I use symlinks in my local site-packages to handle scenarios where I am frequently updating packages:
To use in your projects, just add
'extensions'to yourINSTALLED_APPSsettings.py file (details).Pygments- a generic syntax highlighter for general use in all kinds of software such as forum systems, wikis or other applications that need to prettify source codemdx_codehilite-markdowncode highlighting extension can be installed as well (requiresPygments):mdx_codehiliteis used to added syntax highlighting markup to this blogdateutil- provides powerful extensions to the standard datetime modulepath- provides a class (path) for working with files and directories (less typing than os.path)I've used the
pathpackage for years, but many people are adopting Unipathtwill- a scripting system for automating Web browsing. Useful for testing Web pages or grabbing data from password-protected sites automatically.feedparser- Parse RSS and Atom feeds in Python
Here are a few aliases I have set in my ~/.bashrc file for developing on Leopard:
Download Django For Mac Os X
I wondered if Apple will make Python readily available for Sierra. I just upgraded but, really wish I had not as I have no means to return to El Capitan for gone are the days when we could all rule our own machines, and enjoy doing scripting progrms for our own entertainment such as Hypercard. Those days were better that today when shareware was exciting, and computing a lot more fun. I tried to find out from Apple about any programs I could enjoy in the privacy of my own machine without being expected to join in a world community and wishing to know all about marketing an app for the phone. I am a simple type who likes to make games and ideas for only me, but without knowing 'C' I am stuffed. I may need to buy another computer to gain El Capitain once again or hang around in the Modern world with sierra 'slug', and continue to find my photo disk takes 3 trys to get it to registar, and wonder if I to will be allowed to learn Python or for that use my computer for anything at all without inviting in the Microsoft world of Bill Gates who we all know always uses a third party for nobodys like me, and like most of the USA want a big chunk of everyones life. The money worshipping misers with their mental problem of hoarding are happy. It seems to me that my compuer is nothing really more than a music station and extention of a camera neither of which I am the slightest bit interested in.
MacBook Pro, macOS Sierra (10.12)
Django Tutorial Mac Os X
Posted on
