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

13번째 줄: 13번째 줄:
==설치할 버전 확인==
==설치할 버전 확인==
*http://www.python.org/ftp/python/ 접속하여 원하는 버전이 있는지 확인하자.
*http://www.python.org/ftp/python/ 접속하여 원하는 버전이 있는지 확인하자.
*필자는 2.x 대의 마지막 버전을 추천한다. (여기서는 2.7.4)
*필자는 2.x 대의 마지막 버전을 추천한다. (여기서는 2.7.6)


==다운로드 및 설치==
==다운로드 및 설치==
19번째 줄: 19번째 줄:
<source lang='bash'>
<source lang='bash'>
cd /usr/local/src
cd /usr/local/src
wget -N http://www.python.org/ftp/python/2.7.4/Python-2.7.4.tgz
wget -N http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar xzf Python-2.7.4.tgz
tar xzf Python-2.7.6.tgz
cd Python-2.7.4
cd Python-2.7.6
./configure
./configure
make
make
30번째 줄: 30번째 줄:
<source lang='dos'>
<source lang='dos'>
[root@jmnote ~]# cd /usr/local/src
[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
[root@jmnote src]# wget -N http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
... (생략)
... (생략)
100%[=========================================================>] 14,489,063 2.43M/s  in 9.5s
100%[============================================================>] 14,725,931 3.63M/s  in 5.7s   


2013-04-14 12:39:56 (1.46 MB/s) - `Python-2.7.4.tgz.1' saved [14489063/14489063]
2014-02-07 13:39:43 (2.47 MB/s) - `Python-2.7.6.tgz` saved [14725931/14725931]
</source>
</source>
<source lang='dos'>
<source lang='dos'>
[root@jmnote src]# tar xzf Python-2.7.4.tgz
[root@jmnote src]# tar xzf Python-2.7.6.tgz
[root@jmnote src]# cd Python-2.7.4
[root@jmnote src]# cd Python-2.7.6
[root@jmnote Python-2.7.4]# ./configure
[root@jmnote Python-2.7.6]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux
checking host system type... x86_64-unknown-linux
48번째 줄: 48번째 줄:
</source>
</source>
<source lang='dos'>
<source lang='dos'>
[root@jmnote Python-2.7.4]# make
[root@jmnote Python-2.7.6]# 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 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
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/2to3 from 644 to 755
changing mode of build/scripts-2.7/smtpd.py from 644 to 755
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
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
</source>
</source>
<source lang='dos'>
<source lang='dos'>
[root@jmnote Python-2.7.4]# make altinstall
[root@jmnote Python-2.7.6]# make altinstall
... (생략)
... (생략)
changing mode of /usr/local/bin/pydoc to 755
running install_egg_info
running install_egg_info
Writing /usr/local/lib/python2.7/lib-dynload/Python-2.7.4-py2.7.egg-info
Writing /usr/local/lib/python2.7/lib-dynload/Python-2.7.6-py2.7.egg-info
rm /usr/local/lib/python2.7/lib-dynload/_sysconfigdata.py*
</source>
</source>


72번째 줄: 72번째 줄:
</source>
</source>
<source lang='dos'>
<source lang='dos'>
[root@jmnote Python-2.7.4]# cd
[root@jmnote Python-2.7.6]# cd
[root@jmnote ~]# /usr/bin/python -V
[root@jmnote ~]# /usr/bin/python -V
Python 2.4.3
Python 2.4.3
78번째 줄: 78번째 줄:
<source lang='dos'>
<source lang='dos'>
[root@jmnote ~]# /usr/local/bin/python2.7 -V
[root@jmnote ~]# /usr/local/bin/python2.7 -V
Python 2.7.4
Python 2.7.6
</source>
</source>
구버전은 python_old로 이름을 바꾸고 신버전을 python이라는 이름으로 복사한다.
구버전은 python_old로 이름을 바꾸고 신버전을 python이라는 이름으로 복사한다.
85번째 줄: 85번째 줄:
[root@jmnote ~]# cp /usr/local/bin/python2.7 /usr/bin/python
[root@jmnote ~]# cp /usr/local/bin/python2.7 /usr/bin/python
[root@jmnote ~]# python -V
[root@jmnote ~]# python -V
Python 2.7.4
Python 2.7.6
</source>
</source>



2014년 2월 7일 (금) 13:43 판

upgrading python to 2.7
파이썬 2.7 업그레이드
파이썬 2.7.4로 업그레이드
Python 컴파일 설치

1 설치된 버전 확인

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

2 설치할 버전 확인

  • http://www.python.org/ftp/python/ 접속하여 원하는 버전이 있는지 확인하자.
  • 필자는 2.x 대의 마지막 버전을 추천한다. (여기서는 2.7.6)

3 다운로드 및 설치

명령어
cd /usr/local/src
wget -N http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar xzf Python-2.7.6.tgz
cd Python-2.7.6
./configure
make
make altinstall
실행예시
[root@jmnote ~]# cd /usr/local/src
[root@jmnote src]# wget -N http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
... (생략)
100%[============================================================>] 14,725,931  3.63M/s   in 5.7s    

2014-02-07 13:39:43 (2.47 MB/s) - `Python-2.7.6.tgz` saved [14725931/14725931]
[root@jmnote src]# tar xzf Python-2.7.6.tgz
[root@jmnote src]# cd Python-2.7.6
[root@jmnote Python-2.7.6]# ./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.6]# 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
... (생략)
changing mode of build/scripts-2.7/2to3 from 644 to 755
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.6]# make altinstall
... (생략)
running install_egg_info
Writing /usr/local/lib/python2.7/lib-dynload/Python-2.7.6-py2.7.egg-info
rm /usr/local/lib/python2.7/lib-dynload/_sysconfigdata.py*

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.6]# cd
[root@jmnote ~]# /usr/bin/python -V
Python 2.4.3
[root@jmnote ~]# /usr/local/bin/python2.7 -V
Python 2.7.6

구버전은 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.6

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 }}