python-2.7.2 + setuptool + MySQL-python 설치

python-2.7.2 설치

$ python -V
$ cd /usr/local/src
$ wget http://python.org/ftp/python/2.7.2/Python-2.7.2.tgz
$ tar xvzf Python-2.7.2.tgz
$ cd Python-2.7.2
$ ./configure --prefix=/usr/local/python2.7 --with-threads --enable-shared
$ make && make install

root .bash_profile 추가

alias python="/usr/local/python2.7/bin/python"


심볼릭 링크 생성

ln -s /usr/local/python2.7/bin/python /usr/bin/python2.7


공용라이브러리 등록
$ echo "/usr/local/python2.7/lib" > /etc/ld.so.conf.d/python2.7.conf
$ ldconfig

setuptool 설치 ( yum의 기능과 동일. python 모듈을 저장소에서 찾아 자동 설치 )
$ cd /usr/local/src
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ /usr/local/python2.7/bin/python ez_setup.py

사용예
$ /usr/local/python2.7/bin/easy_install pysqlite


MySQL-python 설치
$ tar xvfz MySQL-python-1.2.3.tar.gz
$ cd MySQL-python-1.2.3
$ vi site.cfg 
   mysql_config의 주석을 제거하고 설치경로 확인
   mysql_config = /usr/local/mysql/bin/mysql_config

$ /usr/local/python2.7/bin/python setup.py build
$ /usr/local/python2.7/bin/python setup.py install


심볼릭 링크 적용
$ ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18


LD_LIBRARY_PATH의 경로를 .bash_profile에 지정

$ vi ~/.bash_profile
    export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
$ source ~/.bash_profile



PIL(Python Image Library) 설치

$ /usr/local/python2.7/bin/easy_install PIL


확인
/usr/local/python2.7/bin/python
>> import MySQLdb
>> import Imaging


출처 - http://yisang3.blogspot.com/2012/03/python-272.html


ez_setup.py 설치 메시지

# python ez_setup.py

Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg

md5 validation of setuptools-0.6c11-py2.6.egg failed!  (Possible download problem?)

# python ez_setup.py

Downloading http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg

Processing setuptools-0.6c11-py2.6.egg

Copying setuptools-0.6c11-py2.6.egg to /usr/lib/python2.6/site-packages

Adding setuptools 0.6c11 to easy-install.pth file

Installing easy_install script to /usr/bin

Installing easy_install-2.6 script to /usr/bin


Installed /usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg

Processing dependencies for setuptools==0.6c11

Finished processing dependencies for setuptools==0.6c11

#


mysql_config를 찾지 못한다면

MySQL-devel를 설치한다.


다음 에러 메시지가 나온다면 

Python.h: 그런 파일이나 디렉터리가 없습니다 

python-devel 를 설치 한다.






'Development > python' 카테고리의 다른 글

python - How do I refer to the null object in Python?  (0) 2015.06.27
Python socket - A simple TCP client  (0) 2012.05.07
Posted by linuxism
,