This article is part 2 of 7 in the series Python SQLAlchemy Tutorial

Last Updated: Thursday 12th December 2013

In the previous article of the series Introductory Tutorial to Python's SQLAlchemy, we learned how to write database code using SQLAlchemy's declaratives. In this article, we are going to learn how to install SQLAlchemy on Linux, Mac OS X and Windows.

Installing SQLAlchemy on Windows

Before installing SQLAlchemy on Windows, you need to install Python using its Windows installer. You can download one of Python's Windows MSI installer at Python's release page. You can install it by double clicking the .msi file.

After you have installed Python on your Windows system, you can download the source code of SQLAlchemy from SQLAlchemy Download Page and install it using its setup.py script.

Installing SQLAlchemy on Linux

It's recommended that we create a virtualenv before we install SQLAlchemy. So, let's go ahead and do that:

Then, the easiest way to install SQLAlchemy is to use Python's package manager pip:

Installing SQLAlchemy on Mac OS X

Installing SQLAlchemy on Mac OS X is relatively the same as Linux. Once you have created a Python virtualenv following the same steps as Linux, you can install SQLAlchemy using the following commands:

That's it. You have successfully installed SQLAlchemy and you can start writing declarative models using the new SQLAlchemy-powered virtualenv right away.

Summary

Under Linux or Mac OS X, it's recommended to install SQLAlchemy inside a virtualenv using pip since it's more convenient than installing it from the source code. While under Windows, you have to install it from the source code using a system-wide Python installation.

About The Author