Skip to content Skip to sidebar Skip to footer

How Do I Install Python/django Modules?

I know absolutely nothing about Django, but I am needing to get an existing project running in OSX. From the project's directory I run python manage.py runserver and get the error

Solution 1:

you can install all dependencies in once, if there is a requirements.txt file! you just have to run the follow command:

pip install -r requirements.txt

otherwise you can install one by one:

pip install django-cms

Here is the PIP documentation: http://pypi.python.org/pypi/pip

if you are used to ruby, you can compared to ruby GEM

Solution 2:

The entries in INSTALLED_APPS are package designations. Packages are a way of structuring Python’s module namespace.

When importing a package, Python searches through the directories on sys.path looking for the package subdirectory.

So python has some designated places to look for packages.

To install packages by name to the right location on your system, you could download some python source code and run the setup.py script (usually provided by libraries and applications).

$ cd /tmp$ wget http://pypi.python.org/packages/source/p/pytz/pytz-2011n.tar.bz2$ tar xvfj pytz-2011n.tar.bz2$ cd pytz-2011n$ python setup.py install

There are, however, shortcuts to this, namely easy_install and it's successor pip. With these tools, installation of a third-party package (or django app) boils down to:

$ pip install pytz

Or, if you use the systems default Python installation:

$ sudo pip install pytz

That's it. You can now use this library, whereever you want. To check, if it installed correctly, just try it in the console:

$ python
Python 2.7.2 (default, Aug 20 2011, 05:03:24)
...>>>import pytz # you would get an ImportError, if pytz could not be found>>>pytz.__version__ 
'2011n'

Now for the sake of brevity (this post is much to long already), let's assume pytz were some third party django application. You would just write:

INSTALLED_APPS = (
    'pytz',
)

And pytz would be available in your project.

Note: I you have the time, please take a look at Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip blog post, which highlights some great python infrastructure tools.

Solution 3:

Well, a little googling wouldn't hurt you ;)

You need a Python package manager such as easy_install and pip. Try this guide:

http://blog.praveengollakota.com/47430655

After that, you can just execute "pip install django-cms"

Post a Comment for "How Do I Install Python/django Modules?"