Learning Python Web programming

The most common frame work Django offers great features for web-programming with python.

I have to take care of pip installation on my mac

easy_install is the way to go, yeh.

Here is another help link for django web-development

It is not surprising that nothing will work as simple as it seems. Well, here the first verification failed:

python manage.py runserver

generates

maximum recursion depth exceeded

Someone kindly posted answer. Well, my functools.py is empty.

The answer is “python” had bugs (working with django), so upgrading python installation solved the problem.

Using MySQL in Django

My database is mysql, so I was tying to incorporate MySQL for django. As usual, nothing works as I expected. When I ran python manage migrate, I got error

….
  File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 28, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
….

So, the problem was the “MySQLdb” module as someone pointed out. Well, again the installation itself reached error

RuntimeError: maximum recursion depth exceeded
/Users/li11/django/mysql/MySQL-python-1.2.4b4/distribute-0.6.28-py2.7.egg
Traceback (most recent call last):
  File "setup.py", line 7, in 
    use_setuptools()
  File "/Users/li11/django/mysql/MySQL-python-1.2.4b4/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/Users/li11/django/mysql/MySQL-python-1.2.4b4/distribute_setup.py", line 125, in _do_download
    _build_egg(egg, tarball, to_dir)
  File "/Users/li11/django/mysql/MySQL-python-1.2.4b4/distribute_setup.py", line 116, in _build_egg
    raise IOError('Could not build the egg.')
IOError: Could not build the egg.

Using PostgreSQL in Django

It turns out that hooking up django with mysql is not that easy, I have got help from Andy who gave me their project on github repository. Well, they sticked with postgresql version 9.4+.

My mac has 9.0, so I have to upgrade it to 9.4+. It seems that postgres.app provides the easiest solution to mac user.

Next, I need to set path for postgresql

Using the Python virtualenv and virtualenvwrapper

Andy’s project needs these prerequisite, and I found this help doc for virtual environment.

Missing llvm-gcc-4.2 on Mac OS

My configuration failed at

pip install -r requirements/dev.txt

With the following error message

    llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.5.5 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DPG_VERSION_HEX=0x09000D -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.7-intel-2.7/psycopg/psycopgmodule.o
    unable to execute llvm-gcc-4.2: No such file or directory
    error: command 'llvm-gcc-4.2' failed with exit status 1

Found a bunch of posting. After upgrading ox-10.11, all works out just fine.

People reported same errors
This one needs compiling from github source
Apple Store is the best answer

I found this website by Marina, I would like to follow this note and get the speed up on python and python web.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.