- upgrading python to 2.7
- 파이썬 2.7 업그레이드
- 파이썬 2.7.4로 업그레이드
- Python 컴파일 설치
1 설치된 버전 확인
![](https://z-images.s3.amazonaws.com/thumb/e/ec/Crystal_Clear_app_xmag.svg/24px-Crystal_Clear_app_xmag.svg.png 1.5x, https://z-images.s3.amazonaws.com/thumb/e/ec/Crystal_Clear_app_xmag.svg/32px-Crystal_Clear_app_xmag.svg.png 2x)
bat
Copy
[root@jmnote ~]# python -V
Python 2.4.3
2 설치할 버전 확인
- http://www.python.org/ftp/python/ 접속하여 원하는 버전이 있는지 확인하자.
- 필자는 2.x 대의 마지막 버전인 2.7.4를 추천한다.
3 다운로드 및 설치
- 명령어
Bash
Copy
cd /usr/local/src
wget -N 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
- 실행예시
bat
Copy
[root@jmnote ~]# cd /usr/local/src
[root@jmnote src]# wget -N 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]
bat
Copy
[root@jmnote src]# tar xzf Python-2.7.4.tgz
[root@jmnote src]# 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
bat
Copy
[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
bat
Copy
[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 바꿔치기
bat
Copy
[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
bat
Copy
[root@jmnote Python-2.7.4]# cd
[root@jmnote ~]# /usr/bin/python -V
Python 2.4.3
bat
Copy
[root@jmnote ~]# /usr/local/bin/python2.7 -V
Python 2.7.4
구버전은 python_old로 이름을 바꾸고 신버전을 python이라는 이름으로 복사한다.
bat
Copy
[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이 제대로 작동하지 않는다...
bat
Copy
[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 파일을 수정하자.
bat
Copy
[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
로 수정하였다...
bat
Copy
[root@jmnote ~]# yum
... (생략)
--samearch-priorities
Priority-exclude packages based on name + arch
Plugin Options:
- → 이제 잘 된다.
6 같이 보기
7 참고 자료
편집자 Jmnote Jmnote bot 103.147.208.88
로그인하시면 댓글을 쓸 수 있습니다.