Trying to branch out in my scope of web development, being mostly a PHP and .NET developer, I decided to try Python. Now I still do not know much about Python development, packages, or even the syntax. Really I am just getting started with it. But I thought I would link to a couple of articles that helped me get setup to develop under OS X for anyone else starting out.
Why try Python?
I started watching some interviews on the yahoo developer network. One in that caught my attention was with Matt Mullenweg, founder of Automattic and developer of wordpress. When asked the question, if you were to start out on a project the size of wordpress today, is there any other language that you would use/consider? And sure enough he answered Python. For the pass couple of years I have thought about using python, and I even once installed it. But that has been as far as I have gotten.
I also started using the website Pownce.com recently. Pownce is a social network allowing you to send messages, files, links, images and video to your friends easily. Well, Pownce who just opened up their site to the public (they where in a private beta for about 6 months) uses the django framework for python for the whole site.
Last Friday I watched a video by Jacob Kaplan-Moss one the the lead developers of django, and found some the of the concepts really interesting. Django was and is developed out of Lawerance Kansas, you know the center of web development. It was built by the web team for the local newspaper in order to better mange the many sites they host and their constantly changing needs. Jacob explains that better than me, if you watch the video. I downloaded the Framework on Friday night (as I was driving back from Kansas City Saturday and Sunday) as something to look at on the way.
Getting Started
Well fortunately Python is included in Leopard, so I didn’t have to download that over my gprs connection in Kansas. Django is very easy to setup, basically run a script from inside the extracted django directory.
sudo python setup.py installOk with that installed where do you start? Django provides a nice walkthrough of setting up a project, what files are included and a step through of the built in features. After following about a page of the walkthrough I got to the point of being ready to sync my DB code with the real database, MySQL.
python manage.py syncdb
You then get this:
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Python/2.5/site-packages/django/core/management.py", line 1672, in execute_manager
execute_from_command_line(action_mapping, argv)
File "/Library/Python/2.5/site-packages/django/core/management.py", line 1571, in execute_from_command_line
action_mapping[action](int(options.verbosity), options.interactive)
File "/Library/Python/2.5/site-packages/django/core/management.py", line 486, in syncdb
from django.db import connection, transaction, models, get_creation_module
File "/Library/Python/2.5/site-packages/django/db/__init__.py", line 11, in <module>
backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE, {}, {}, [''])
File "/Library/Python/2.5/site-packages/django/db/backends/mysql/base.py", line 12, in <module>
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
So where as Python is installed by default under OS X, the mysql package is not.
How to install MySQLdb Package for Python.
First I went to the Mysql Downloads page and got a copy of the MySQLdb Package
Download the package, extract it, and open Terminal.app and change directories to the newly extracted package.
Here is where I ran into some fun, how do you install this? Well I found a website that suggested the Easy Installer…and that sounded nice, so I downloaded it first.
Download ez_setup.py, and run it; this will download and install the appropriate setuptools egg for your Python version.
There are many ways on install a package with the Easy Installer, I choose the directly from an unzip source folder, since that is what we have. And you can find more directions about the Easy Installer here
Now that you have Easy Installer, well installed, from terminal.app in the extracted MySQLdb Package MySQLdb folder run:
easy_install .
Got some errors, yeah we all did.
First, python will not be able to find your mysql installation (you did install mysql right?) If you didn’t get the .dmg file from the Mysql website, and install it through their very easy and very friendly installer, including a preference pane. The only problem with this it it puts itself in a non-standard folder, and that will cause a couple of issues.
Python will not be able to find mysql_config, or mysql for that matter because it is not in your path. To add it to your path add this line to the .profile file in your home directory.
PATH="${PATH}:/usr/local/mysql/bin"
Save that, and close terminal.app, and reopen it, This will cause the .profile to be re-read and your new addition to the path to be evaluated. Go ahead a try, now from the command line you should be able to call mysql_config, and any other mysql executable for that matter.
Try and run that easy_install command again, and yes you will still get errors.
Now you should get something like:
Running MySQL-python-1.2.2/setup.py -q bdist_egg --dist-dir /var/folders/At/At0AMaeKEAaYVW-LYfH6e++++TI/-Tmp-/easy_install-BUSsM_/MySQL-python-1.2.2/egg-dist-tmp-qFBtdU
In file included from /usr/local/mysql/include/mysql.h:43,
from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
error: Setup script exited with error: command 'gcc' failed with exit status 1
Now to edit a couple of the files that came with the MySQLdb package. First _mysql.c
comment out the following lines:
#ifndef uint
#define uint unsigned int
#endif
Also edit the site.cfg file and change
threadsafe = True
to
threadsafe = False
Next, just one more Mysql Path fix run the following command:
sudo ln -s /usr/local/mysql/lib/ /usr/local/mysql/lib/mysql
Python will now be able to find the lib files where they should be. Ok that is it, run the easy_install . command and everything should go smoothly. As far a django is concerned, just continue to follow the walkthrough and you should do fine. I hope this helped.
Here are the websites that helped me, So if you run into any other issues these would be a good place to start:
I ran into the same problem, but this all worked great. Thanks for the post!
Hey Elee your welcome. I’m glad someone found it useful.
Thank you so much! That worked perfectly. You probably saved me hours of agony!
[...] and sweet … here are the references I used: How to install Django with MySQL on Mac OS X Notes: installing Django / Python / Mysql on OS X ………Tags » django [...]
Just a pointer from a Unix user: where you suggest closing and reopening the Terminal window, you can just type PATH=”${PATH}:/usr/local/mysql/bin” into the command line directly, the PATH for the current Terminal window will be changed and you can go about your business. Saving that line in the ~/.profile, ~/.bashrc or ~/.zshrc files will mean that your shell (sh, bash or zsh respectively) will automatically include that modification to the PATH variable.
You could even edit the ~/.profile file, then type “source ~/.profile” and it will achieve the same result.
Hope this helps someone!
Thank you so much! Your solution was right on the spot!
Exellent post!
Worked at first time!
glad to know the solution still works. Did you use the latest version of django?
Yes, I did use the latest version ( at least for MAC ) but it didn't work for the development version.
And I'm using the Python version that comes already installed. The newest version ( I think ) it already comes with MySQLdb pre-installed.
Thanks a lot, this really helped me and saved me a lot of time.
I am on Mac machine. Ahh getting it runnin is al pain…typical erros apart form the one which u have meniotned were the 32 bit python runnin on 64bit mysqldb driver….In this case u will have to install the 32 bit version. Also install the right mysql package – check if ur ac is a intel x86 or a PPC…i ignored it and spent a day on it. – Amey Kanade
No, sadly could not get it working. This process is too convoluted and if things don't go as advertised (and they didn't) then it's a dead end. I'll have to wait until someone writes a proper installer.
Костанай знакомства
Как определить беременность
програма для поиска мобильного телефона
V1tybz aeproanwlodd, [url=http://cpatsvsttdna.com/]cpatsvsttdna[/url], [link=http://eruuuzoqzglx.com/]eruuuzoqzglx[/link], http://tgglqgbwexnl.com/
Проститутки шадринск
Как запрограммировать пол ребенка
отправить смс с заменой номера
Hey nice article thanks a lot for this one.
FYI: I think they have fixed the issues. After running eazy install and adding mysql_config to the path everything worked for me.
Python 2.6.4
MySQL_python-1.2.3c1
Нам очень понравился Ваш проект и мы хотели бы предложить помощь в раскрутке Вашего сайта
В настоящее время в стандартный комплект входит за 10 у.е:
1) 11 тем ТИЦ и PR
2) 2 темы накрутки трафика
3) Базы кеев и ключевых сло
4) Синонимизатор + рерайтер с базами
5) Парсеры и граберы контента
6) Скрипты и программы поиска свободных доменов с ТИЦ, в т.ч. скрипт поиска 100% не бан
7) Перехватчик доменов с ТИЦ
Аська 577716240 Отзывы http://forum.searchengines.ru/forumdisplay.php?f=17
…
…
…
…
There are still some other things to consider, but I agree with what you’re saying. Good point.
И где вы тут видите смысл? Абсурд какой-то…
Это сообщение, бесподобно )))
Last week I dropped by this site and as usual great content and ideas. Love the lay out and color scheme. Is it new? Well I really really like it. Email me the theme at joanbm3@gmail.com. I love the tips on this site, they are always to the point and just the information I was looking for. Its hard to find good content these days in the world of spam and garbage sites.
Your missing a step. you need setuptools installed. http://www.errorhelp.com/search/details/74034/imp...
Loved reading this post, do you also have some sort of newsletter?
Sorry for the double post, but i\’m trying to read this blog through RSS and its not working – any ideas?
Hi, good day. Wonderful post. You have gained a new subscriber. Pleasee continue this great work and I look forward to more of your great blog posts.
I have been a reader for a long time, but am a first time commenter. I just wanted to say that this has been / is my favorite entry of yours! Keep up the good work and I’ll keep on coming back.
Tasarim ve icerik olarak guzel bir blog, tebrikler.
If you're having trouble getting it installed the new version of mysql-python requires some different instructions, also if you're using 64 or 32 bit versions of python or mysql will make a difference. There's some information here:
http://learninglamp.wordpress.com/2010/02/21/mysq...
Greets everyone!
I just wanted to say hi to everyone
Cheerio
[URL=http://www.vpnmaster.com][IMG]http://openvpn.net/archive/openvpn-users/2005-05/pngd55nFojmJX.png[/IMG][/URL]
В Голландии появилась новая услуга, [url=http://bit.ly/cBGI7B ]платная подруга[/url]
она поговорит с вами по телефону, составит компанию по магазинам, пойдет с вами в кафе и если нужно припрется наночь глядя с бутылкой вина поговорить по душам.
И ничего не потребует взамен, кроме 50 евро в час.
Презентуем полезный сайт про рецепты из лесных ягод. На этом веб ресурсе вас ожидает множество энциклопедических заметок про калину и костянику. Предлагаем Вам информационные материалы и статьи про боярышник, кизил и можжевельник. Здесь Вы найдете справочные сведения о бузине и сливе, землянике и черемухе.
Поддерживаю пост хороший вышел. Закладываюсь!
oh hell yeahhh
В Голландии появилась новая услуга, [url=http://bit.ly/9Bmh23 ]платная подруга[/url]
она поговорит с вами по телефону, составит компанию по магазинам, пойдет с вами в кафе и если нужно припрется наночь глядя с бутылкой вина поговорить по душам.
И ничего не потребует взамен, кроме 50 евро в час.
Кто может подсказать что вот [url=http://bit.ly/9s3rO8 ]это[/url] такое?
satellite tv for pc
satellite tv for pc
_________________
[url=http://www.youtube.com/watch?v=CgJrK42dTSg]satellite tv for pc[/url]
zPONYCrf Cheap Ativan
I found your web page from bing and it is superb. Thankx for providing such an informative post!!!!
aVqHdjqg Buy Ambien
I just found this blog recently when a friend of mine suggested it to me. I have been an avid reader ever since.
He is simply so lovely!
Justin Bieber may be my favorite! He is totally cute!
Dear friends,
My name is Adelina. I am a 22 years girl from Italy. I was looking for a free translation software and I found one.
Program’s name is Babel Fish and iIt supports 75 languages. I installed it but I could not understand how to use it. I am not a computer expert. Can someone help me please on how to run this.
The link is here:
http://access.im/3/babelfish
I thank you very much for your help.
pewFwG Cheap Valium
Если честно, случайно попал на этот форум, но похоже попал как раз туда, куда надо…
Ну перво наперво разрешите поприветствовать всех)
Никогда не думал, что жизнь меня заставит обратиться к кому-либо по каким либо жизненным вопросам, ибо всегда искренне был уверен, что человек по сути не такое глупое существо, что бы не суметь разобраться в себе и своих проблемах. Считал, что те, кто обращаются, им просто лень покопаться в себе. Видимо за это и поплатился. Вижу, что моих познаний уже далеко не хватает, что бы сложившуюся ситуацию хоть как то «разрулить»… Именно поэтому и обращаюсь…
Конечно понимаю, что в двух словах не рассказать всех обстоятельств, а тем более нюансов, но попробую хоть что то для начала:
Мне 29, будучи женатым, повстречал замужнюю, ну и как говориться завертелось, закружилось…
[url=http://bit.ly/dCqA1C ]Продолжение[/url]
Once upon a time air travel was a great deal simpler than it is today. You called one of a few airlines that flew from your airport, the agent would tell you what flights were available for a given time, and you booked the one you wanted. Airports were always bustling places, especially during the holidays, but as long as you gave yourself adequate time, the process was usually the same. You would check your bags, go through the x-ray machine, get your boarding pass, and wait patiently at the appropriate gate. Once you got on the plane you ate the snack or meal that came with your flight and watched a movie.
In recent years travel by plane has become significantly more complicated. There are so many different configurations for flights and types of fares. Dire economic circumstances have caused airlines to raise rates and charge extra fees for everything from baggage to blankets. There are complex rules about what you can and cannot carry in your luggage. It can be very difficult to determine whether you are getting the best deal or the best services when you buy an airline ticket. The internet makes the navigation of airlines, airports, and flight itineraries easier, but, even so, be prepared to do some research if you want to find a flight at the best price.
Here is something up front that might save you time and money right off the bat. If you are traveling within the United States mainland, always look at Southwest Airlines first. Southwest is almost always the best deal you will find. However, Southwest itineraries do not appear on the major travel websites, so always go directly to the airline’s website for information. Plug in your travel plans, and you will get a list of all the flights that are available. Southwest typically charges more reasonable prices than other airlines, and there are no hidden fees. The price you see is the price you get although tax and the government fee that is attached to all flights does apply. For lower prices than you can probably get anywhere else look at the “web only” fares, but keep in mind that these fares are not refundable.
[url=http://cheapairtickets.qarri.com/]Cheap air tickets- guide[/url]
нашим делом не заключенные получат завтрака. [url=http://mis-margarita.t35.com/shlyukhi-m-partizanskaya.html]Шлюхи М Партизанская [/url] Проститутки волжского и волгограда Радостное тявканье эхом отдавалось в [url=http://mis-miroslava.t35.com/shlyukhi-piter-m-ladozhskaya.html]Шлюхи Питер М Ладожская[/url] штыками вообще остальные надевали наручники на осужденного, пропускали цепь через них цепь часто прикрепляли к своим поясам и туго вдоль бедер. [url=http://mis-lapa.t35.com/shlyukhi-m-sevastopolskaya.html]Шлюхи М Севастопольская[/url] Элитные Шлюхи Города Вологды часов восемь ручные часов восемь долгие часов. [url=http://mis-nargiz.t35.com/shlyukhi-prostitutki-g-nizhnij-novgorod.html]Шлюхи Проститутки г Нижний Новгород[/url]
рядами с оловянными мисками фарфоровыми мисками в руках с ведерками а два стражника ходили между ними и накладывали рис после казни было созерцать другую сцену приятно и радостно. [url=http://mis-ulenka.t35.com/individualki-g-yaroslavl.html]Индивидуалки г Ярославль[/url] Индивидуалки Измайлово ночном воздухе раздался, слабый звук падения донесшийся из армейских казарм. [url=http://mis-toma.t35.com/shlyukhi-metro-avtozavodskaya.html]Шлюхи Метро Автозаводская[/url] домашнем костюме и очках замахал опытной рукой. [url=http://mis-natashka.t35.com/najti-prostitutku-v-ufe.html]Найти Проститутку в Уфе[/url] Вызвать Проститутку в Стерлитамаке Осужденный не находился на болезненном [url=http://mis-olimpiya.t35.com/shlyukhi-krasnye-vorota.html]Шлюхи Красные Ворота[/url]
или два штыка дрожали. [url=http://mis-marianna.t35.com/shlyukhi-m-bratislavskaya.html]Шлюхи М Братиславская[/url] Мгновение в восторге кружил ему [url=http://mis-svetik.t35.com/shlyukhi-spb-m-avtovo.html]Шлюхи Спб М Автово[/url] осужденный носки оттянуты вниз без сомнения.
I really like this site and Notes: installing Django / Python / Mysql on OS X | DavidMichaelThompson . I read about you on another site called http://www.kindle-sales.com and thought they had great views as well.