"리눅스 Python 2.7 컴파일 설치"의 두 판 사이의 차이

138번째 줄: 138번째 줄:


[[분류: python]]
[[분류: python]]
[[분류: 컴파일 설치]]

2013년 11월 24일 (일) 09:33 판

upgrading python to 2.7
파이썬 2.7 업그레이드
파이썬 2.7.4로 업그레이드

1 설치된 버전 확인

[root@jmnote ~]# python -V
Python 2.4.3

2 설치할 버전 확인

3 다운로드 및 설치

명령어
wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
tar xzf Python-2.7.tgz
cd Python-2.7
./configure
make
make altinstall
실행예시
[root@jmnote ~]# wget http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
... (생략)
100%[=========================================================>] 14,489,063  2.43M/s   in 9.5s

2013-04-14 12:39:56 (1.46 MB/s) - `Python-2.7.4.tgz.1' saved [14489063/14489063]
[root@jmnote ~]# tar xzf Python-2.7.4.tgz
[root@jmnote ~]# cd Python-2.7.4
[root@jmnote Python-2.7.4]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux
... (생략)
creating Modules/Setup
creating Modules/Setup.local
creating Makefile
[root@jmnote Python-2.7.4]# make
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
... (생략)
creating build/scripts-2.7
changing mode of build/scripts-2.7/smtpd.py from 644 to 755
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
[root@jmnote Python-2.7.4]# make altinstall
... (생략)
changing mode of /usr/local/bin/pydoc to 755
running install_egg_info
Writing /usr/local/lib/python2.7/lib-dynload/Python-2.7.4-py2.7.egg-info

4 바꿔치기

[root@jmnote ~]# ll /usr/bin/python*
-rwxr-xr-x 1 root root    8304 Sep 22  2011 /usr/bin/python
lrwxrwxrwx 1 root root       6 Nov  1  2011 /usr/bin/python2 -> python
-rwxr-xr-x 1 root root    8304 Sep 22  2011 /usr/bin/python2.4
[root@jmnote Python-2.7.4]# cd
[root@jmnote ~]# /usr/bin/python -V
Python 2.4.3
[root@jmnote ~]# /usr/local/bin/python2.7 -V
Python 2.7.4

구버전은 python_old로 이름을 바꾸고 신버전을 python이라는 이름으로 복사한다.

[root@jmnote ~]# mv /usr/bin/python /usr/bin/python_old
[root@jmnote ~]# cp /usr/local/bin/python2.7 /usr/bin/python
[root@jmnote ~]# python -V
Python 2.7.4

5 yum 오류 고치기

python에 의존성이 있던 yum이 제대로 작동하지 않는다...

[root@jmnote ~]# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.4 (default, Apr 14 2013, 12:44:22) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://wiki.linux.duke.edu/YumFaq

다음과 같이 /usr/bin/yum 파일을 수정하자.

[root@jmnote ~]# cp /usr/bin/yum /usr/bin/yum_old
[root@jmnote ~]# sed -i 's/\/usr\/bin\/python/\/usr\/bin\/python2.4/g' /usr/bin/yum
[root@jmnote ~]# diff /usr/bin/yum_old /usr/bin/yum
1c1
< #!/usr/bin/python
---
> #!/usr/bin/python2.4
→ 파일의 1행에 있는 #!/usr/bin/python#!/usr/bin/python2.4로 수정하였다...
[root@jmnote ~]# yum
... (생략)
  --samearch-priorities
                        Priority-exclude packages based on name + arch

  Plugin Options:
→ 이제 잘 된다.

6 같이 보기

7 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}