Archive for Apple

MySQL-python in Leopard.

Python and mysqldb

Installing the python library for MySQL in Leopard can be a bit tricky. If you’re an easy_install lover, the first thing to try would be:

$ sudo easy_install MySQL-python

But the results you’ll obtain will be not very encouraging.

Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python
Reading http://sourceforge.net/projects/mysql-python/
Best match: MySQL-python 1.2.2
Downloading http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz
Processing MySQL-python-1.2.2.tar.gz
Running MySQL-python-1.2.2/setup.py -q bdist_egg –dist-dir /tmp/easy_install-07GTpt/MySQL-python-1.2.2/egg-dist-tmp-t78bko
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
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
In file included from /opt/local/include/mysql5/mysql/mysql.h:47,
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
lipo: can’t open input file: /var/tmp//cczla7iC.out (No such file or directory)
error: Setup script exited with error: command ‘gcc’ failed with exit status 1

But the solution is there. As you can see, the command talks about an error in line 40 for some file called _mysql.c. We’re going to get to that file and remove one line.

First we need to download the package. We will use easy_install, but later. So now grab your wget or your browser to here. And when you have the file, uncompress it (terminal or through finder).

$ wget http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz

$ tar xzf MySQL-python-1.2.2.tar.gz

Now go to the directory that has just been created and open the file _mysql.c. Go to the line number 38.

35 #include “my_config.h”
36 #endif
37 #ifndef uint
38 #define uint unsigned int
39 #endif
40 #include “mysql.h”

Delete line 38, save and install your modified egg from the parent directory with:

$ easy_install MySQL-python-1.2.2
Processing MySQL-python-1.2.2
Running setup.py -q bdist_egg –dist-dir /Users/alff/tmp/MySQL-python-1.2.2/egg-dist-tmp-S4uIM7
ld: warning in /opt/local/lib/mysql5/mysql/libmysqlclient_r.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libz.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libssl.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libcrypto.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents…
Adding MySQL-python 1.2.2 to easy-install.pth file
.
Installed /Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg
Processing dependencies for MySQL-python==1.2.2
Finished processing dependencies for MySQL-python==1.2.2

The problem was that _mysql.c defined the type unit and that type is defined again when it includes the file mysql.h. We remove the duplicate, the compiler is happy :)

Edit: If you installed mysql5 with MacPorts, and you get the error EnvironmentError: mysql_config not found when installing the egg. Just add a link from mysql_config to mysql_config5.

# which mysql_config5
/opt/local/bin/mysql_config5
# cd /opt/local/bin/
# ln -s mysql_config5 mysql_config

Tags:, , , , , »
Comments (2) »

You can find a Mac fan everywhere.

Mac fans everywhere.

Sometimes you walk in the street and you don’t pay attention to the multiple details the objects placed in your way offer to you. But also you have to stop form time to time to see what’s around you. And you can find hidden Mac fans like the one in the picture.

I went to pick money from ATM and I don’t know why, I walked around the area and found this Apple labeled scooter. As you know there are multiple places where to put that sticker.

Tags:, , , »
No comment »

Installing pycurl in MacOS Leopard

Lib Curl

Leopard comes with Python 2.5.1. And it’s nice to be able to use easy_install to add python packages, but it can happen that some of those libraries depend in their C/C++ counterparts, and they are a bit outdated in Leopard.

My case was with pycurl. Leopard python doesn’t come with pycurl. However it includes cURL and libcurl version 7.16.3.

$ curl –version
curl 7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz

If I try to install pycurl from easy_install, I get this message regarding the version of the C version of the library

$ sudo easy_install-2.5 pycurl

Using curl-config (libcurl 7.16.3)
src/pycurl.c:55:4: error: #error “Need libcurl version 7.16.4 or greater to compile pycurl.”

I have also macports, so I tried to install the version requiered through macports. It´s not an upgrade, because you continue having the original Leopard version plus the new one in the /opt directory.

$ port search curl

curl net/curl 7.18.0 Tool for transferring files with URL syntax
$ sudo port install curl
—> Fetching curl
—> Verifying checksum(s) for curl
—> Extracting curl
—> Configuring curl
—> Building curl with target all
—> Staging curl into destroot
—> Installing curl 7.18.0_0
—> Activating curl 7.18.0_0
—> Cleaning curl

Seems that everything is ok. But before you run to run easy_install again, you have to realize that easy_install doesn’t know anything about your new curl installation of curl in /opt. easy_install will use curl-config to determine the location of the curl library. So, if you update your PATH (if you don’t ave it already) adding the /opt entry in the beginning, everything will be solved.

$ curl-config –version
libcurl 7.16.3
$ export PATH=/opt/local/bin/:$PATH
$ curl-config –version
libcurl 7.18.0

Now the installation will proceed:

$ sudo easy_install pycurl
Searching for pycurl
Reading http://pypi.python.org/simple/pycurl/
Reading http://pycurl.sourceforge.net/
Reading http://pycurl.sourceforge.net/download/
Best match: pycurl 7.16.4
Downloading http://pycurl.sourceforge.net/download/pycurl-7.16.4.tar.gz
Processing pycurl-7.16.4.tar.gz
Running pycurl-7.16.4/setup.py -q bdist_egg –dist-dir /tmp/easy_install-f4LJrU/pycurl-7.16.4/egg-dist-tmp-9l6i1M
Using curl-config (libcurl 7.18.0)
ld: warning in /opt/local/lib/libcurl.dylib, file is not of required architecture
ld: warning in /opt/local/lib/libz.dylib, file is not of required architecture
zip_safe flag not set; analyzing archive contents…
Adding pycurl 7.16.4 to easy-install.pth file
.
Installed /Library/Python/2.5/site-packages/pycurl-7.16.4-py2.5-macosx-10.5-i386.egg
Processing dependencies for pycurl
Finished processing dependencies for pycurl

And we’re ready to rock’n'roll:

>>> import pycurl
>>> pycurl.version
‘libcurl/7.18.0 zlib/1.2.3′
>>> c = pycurl.Curl()
>>> c.setopt(pycurl.URL, “http://www.google.com”)
>>> c.setopt(pycurl.FOLLOWLOCATION, 1)
>>> c.perform()
… (dumped html) …
>>> c.getinfo(pycurl.HTTP_CODE)
200

:)

Tags:, , , , »
Comments (1) »

And yet again, I survive

The best place to relax

I guess it’s time to write something for all those friends that have a link here or even have me in their RSS feeds. At least to listen to this heartbeat and understand that I’m alive and I haven’t died abroad/here (choose the right for you).

I’ve been 2 months working in an ISP here in Athens. Despite the big company and the really good opportunities I still don’t have a workstation. In fact I have only a box and something you can name “screen”, but no keyboard, mouse, mouse pad or power cable. I work arround 55 hours per week and I get paid for 40, and even with that my work doesn’t get a defined course/direction/objective. Each week I end up tired and blaming myself for being so stupid and not doing anything, but each Monday I find a reason to continue (that gets destroyed by Tuesday/Wednesday).

We don’t use any kind of software engineering process, even we do not document a word (as a rule, lucky you if you find a comment). And we don’t have a really good plan to organize the work: you’re supposed to end an important project for the company one day but at the same time they do not hesitate in changing that idea to: fix something, develop another thing that has been in the shadow for weeks, or answer pathetic emails (pathetic but really really funny). The last thing that scared me is that the managers are trying to define their business logic from the software. I shouldn’t be the opposite? You define the logic and then build the software to support it.

Last week while I was blaming myself for being so stupid to accept those conditions I received a call from another company. I went to the interview and even for the same money (a bit more)… surprise, they don’t do overtime and if we do we can exchange for free time…. But for some of my managers “those companies doesn’t exist” Yeah! the reality of the coder that became codeer (because I cannot call that engineer). So even if now I live 3 minutes far away from my office, I plan to move to a new job 45 minutes far away. Am I stupid?

But I guess I should not come here only to swear a bit about “bad things”. This is also a nice space to talk about nice and great things. Like my small apartment :) I’ll post more pictures but this is me enjoying the IKEA sofa-bed (yes! you can come to visit me to Athens!) that took 3 weeks to arrive. IKEA sofa with IKEA tables (the 3 you can see), IKEA chair and library. (No, the notebook is not from IKEA, they cannot do something so good). Stella helped me a lot with the house, so this is her space to receive (another) big EFXARISTO!


Comments (3) »

Mac weird message

Mac error

The world of computers is full of weird errors, and Mac OS X its not free of those stupid errors. As you can see in the screenshot, there is an error window telling something like “The bootdisk is almost full” near the harddrive properties showing 96GiB free.

The error started to appear in the afternoon and some java applications stopped working. Then I realized that when I run the application Im developing, the application crash and that error appears. Why a user-space application can make that screen appear? After that I checked the harddrive, but the disk utility froze the system. I used that utility from the boot dvd and no errors were reported, but trying again in the OS: all the system frozen.

I reinstalled, and I was able to check my harddrive for errors without the disk utility crashing and freezing the system. But I got again the “low space” window. I deleted some cache from the libraries I’m using, and I got rid from the error.

But Im still thinking about that user-space / error window link. Is Mac OS user-space application errors resistant? I guess there is a leak hidden out there (Like X-Files)

Now its time to kill some mosquitoes! They’re invading my room!


Comments (2) »

Mac Mac Mac mac mac mac …


Mac geek 1

There are some kind of products whose users are branded as geeks, addicts or fanatics. I guess that is that people that brand you as a mac geek, makes you a mac geek, even if you are not. So, encouraged by those people I felt the need of “renew” my faith on the big apple (or small apple). Even they don’t pay me for doing this (they should), I prepared this present for a good friend.

I thought in a string with an apple in the front but I wanted a big apple. Something like “hey! look at my apple” :P Therefore, even the “apple string” is more sexy. I prepared the “big apple in your ass” option :P But as you can see in these pictures, no one tried it on. The pictures with it put on I reserve them for my private gallery :D .

Have a great Mac  day!.

Mac geek 2


Comments (2) »

The Λέσχη

Apple (real one)

For a student who lives in a flat with no so many tools to cook, not so many time to spend cooking, and the most important: with no so many “energy” to cook (yep, I’m lazy). For a person who fulfil those characteristics the student restaurant is the best place to eat healthy and cheap.

The first is cheap, beacuse you can eat for 2 euros or 1 euro with a 15 days luncheon voucher. That’s in Irakleio, in Patra you pay 1,9€ and you can have lunch and dinner, free salad an fresh water (from the tap). In Irakleio you have to pay for a bottle of water, there is no tap, and you can only pick one salad and a piece of fruit.

Healthy. Not so many people can say that the food from the student’s restaurant is healthy. It’s not always good, and some days it s***s. But you can find fish, vegetables and other things that your mother told you to eat and you always forget to buy in the supermarket :P

Well, to finish, the picture was taken in one of those “Apple Lover” moments one have every day. As you can see my skills with the knife are not very good, so I will not open a shop selling that stuff. But it’s something funny :D


No comment »

Μηλαράκι

milaraki

If you use a MAC, for sure you have given a name to that special key with an apple. Its like the control key in Windows, but with its own style: apple+c to copy, apple+v to paste, and so on and so forth. In Spanish I use to say “manzanita” that means little apple. I thought it was typical from the Spanish language, that in other languages will be something or standard like “apple key” or strange and you cannot imagine. Until you arrive to Greece and you listen to μηλαράκι (milaráki).

Apple in Greek is μήλo (mílo), and Greece is the country of “I’d want a little bottle of little water, little please”. Everything is cute and little. So for the magic apple key, they had to say… little apple. Now I know how to say apple :D I cannot forget that, because if a Greek friend asks me about how to copy&paste in my computer, I say “press μηλαράκι…” :P

Time to leave to visit a teacher and download the last ep. of Heroes. I’m addicted.


Comments (1) »