Skip to content

CentOS 6.5 + Python2.7 + MySQL_Python-1.2.3

조회 수 7943 추천 수 0 2014.03.28 16:56:04
YUM 설치 하면 간단 한거지만 특정프로그램 사용을 인하여 삽질을 기록 합니다. 

Python2.7 설치는 간단하기에 생략하고 
MySQL_Python-1.2.3 연동 설명만 합니다.

우선 MySQL_Python-1.2.3 설치 하기 위해서는 setuptools 필요 합니다.

아래는 setuptools설치 화면 입니다.

[root@ MySQL-python-1.2.3]# ../bin/python2.7 ez_setup.py -U setuptools

Searching for setuptools
Reading https://pypi.python.org/simple/setuptools/
Reading http://peak.telecommunity.com/snapshots/
Reading https://pypi.python.org/pypi/setuptools
Best match: setuptools 3.3
Processing setuptools-3.3-py2.7.egg
setuptools 3.3 is already the active version in easy-install.pth
Installing easy_install script to /opt/hqueue/bin
Installing easy_install-2.7 script to /opt/hqueue/bin

Using /opt/hqueue/lib/python2.7/site-packages/setuptools-3.3-py2.7.egg
Processing dependencies for setuptools
Finished processing dependencies for setuptools




MySQL-python-1.2.3 빌드 진행 한다

[root@RND003 MySQL-python-1.2.3]# ../bin/python2.7 setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
building '_mysql' extension
gcc44 -fno-strict-aliasing -O3 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/opt/hqueue/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-prote다ctor --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
In file included from /usr/include/mysql/my_config.h:14,
                 from _mysql.c:36:
/usr/include/mysql/my_config_x86_64.h:422:1: warning: "HAVE_WCSCOLL" redefined
In file included from /opt/hqueue/include/python2.7/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/opt/hqueue/include/python2.7/pyconfig.h:902:1: warning: this is the location of the previous definition
gcc44 -pthread -shared -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/lib build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/python2.7/python_ucs4/lib -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status
error: command 'gcc44' failed with exit status 1
[root@MySQL-python-1.2.3]# 

python2.7 경로를 찾지 못하여 에러로 인해 진행 빌드 진행 안됨


참고: CentOS 6.5 gcc44 이름으로 RPM 패키지가 없음
        gcc44 찾지 못할경우 : ln -s /usr/bin/gcc /usr/bin/gcc44 심볼링크 걸어 준다


방법 1 
에러 메세지 중에  -lpython2.7 구간을 삭제후 아래처럼 커맨드로 입력 후 so 파일을 만든다.

gcc44 -pthread -shared -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/lib build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/python2.7/python_ucs4/lib -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl  -o build/lib.linux-x86_64-2.7/_mysql.so


방법2
에러 메세지 중에  -lpython2.7 구간을 삭제후  -L/파이선설치경로/lib 경로를 입력 후 so 파일을 만든다.

gcc44 -pthread -shared -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/lib build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/파이선설치경로/lib -L/home/prisms/builder-new/WeeklyDevTools/dev_tools/local/python2.7/python_ucs4/lib -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/_mysql.so

커맨드로 입력후 정상적으로 진행 되면 아무러 메세지가 나오지 않음



so 파일이 생성되어 인스톨로 바로 진행 한다


[root@MySQL-python-1.2.3]# ../bin/python2.7 setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql_exceptions.py -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql.so -> build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/cursors.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/release.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/connections.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/times.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/converters.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb
creating build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FLAG.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/ER.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CR.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
byte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.7-linux-x86_64.egg
Copying MySQL_python-1.2.3-py2.7-linux-x86_64.egg to /opt/hqueue/lib/python2.7/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file

Installed /opt/*****/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3

[root@ src]# /opt/******/bin/python2.7
Python 2.7.5 (default, Oct 24 2013, 12:22:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> 
위 하면은 연동 함수 테스트 화면이다 아무로 메세지가 없어야 정상

아~~ 드뎌 설치 이거 설치 하려고 4일간 삽질을 했다 ㅠ.ㅠ
팀장님이 알려주신 방법으로 30분도 안걸렸다는게 허무함 ㅠ.ㅠ


profile

일요일은 짜빠게뤼~ 먹는날~^^

엮인글 :
http://adminplay.com/278483/022/trackback
List of Articles
번호 제목 글쓴이 날짜 조회 수
347 SSL 패스워드 삭제 하기 ADMINPLAY 2014-04-27 5346
346 SCM - 캐시 서버 구축 (Squid in Linux) ADMINPLAY 2014-04-27 8229
345 CentOS Linux Remote Desktop 에서 로그인 화면보기 ADMINPLAY 2014-04-14 7797
344 CentOS 자동로그인 설정 ADMINPLAY 2014-04-14 8826
343 Linux Command 로 Mysql table drop 방법 ADMINPLAY 2014-04-07 5696
342 gcc Library 경로 지정 ADMINPLAY 2014-04-07 6007
341 CentOS 5.6 + NginX 0.8.54 + Django 1.3 (FastCGI) + Pyt... ADMINPLAY 2014-03-28 6163
» CentOS 6.5 + Python2.7 + MySQL_Python-1.2.3 ADMINPLAY 2014-03-28 7943
339 python과 mysql 연동시 libmysqlclient_r.so.* 에러가 날 ... ADMINPLAY 2014-03-27 5518
338 python mysql connector 설치 및 SQLAachemy 연동 ADMINPLAY 2014-03-27 7875
337 SVN 클라이언트 명령어 ADMINPLAY 2014-03-18 7429
336 CentOS 6.X GUI 로그인 화면에서 로그인 했던 계정 리스트... ADMINPLAY 2014-03-05 16647
335 OS X 매버릭스가 NAS, 윈도우 PC 등 SMB 장비에 연결하지 ... ADMINPLAY 2014-03-04 6735
334 OS X 10.9 매버릭스의 기본 파일공유 프로토콜은 AFP가 아... ADMINPLAY 2014-03-04 10984
333 telnet 과 ssh 의 차이점 ADMINPLAY 2014-03-01 6454
332 vimrc 설정 file ADMINPLAY 2014-03-01 6082
331 Linux 마우스 휠 방향 바꾸기 (mac 처럼 마우스 휠 바꾸기) ADMINPLAY 2014-02-27 11840
330 디스크 UUID 변경후 하드부팅정보 수정하기 ADMINPLAY 2014-02-26 21008
329 linux daemon (리눅스 데몬 설명) ADMINPLAY 2014-02-26 647768
328 Strace - 시스템콜과 신호 추적 file ADMINPLAY 2014-02-25 6043

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234