[python] 파이썬 2.7 용 pip 설치하기

python pip install for CentOS

python 2.7.6을 centos 6.5에 설치했다.
파이썬 2.7.6 centos에 설치하기

이제 장고를 설치하려는데 일단 패키지 매니저(pip)부터 설치를 해보자

파이썬 패키지 매니저를 설치하기 앞서 sudo 했을 때 PATH를 확인하자.

sudo env |grep PATH

/usr/local/bin이 없으면 아래 내용을 /etc/profile에 추가하고 shell을 재실행한다.

vi /etc/profile
alias sudo='sudo env PATH=$PATH'
wget http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip

pip를 실행해보자.

[python] 파이썬 2.7.6 설치 with CentOS 6.5

centos에 파이썬이 기본적으로 설치되어 있는데 버전이 2.6이다.
파이썬 2.7을 설치해보자.

파이썬 설치를 해보자.
python 2.7.6 install with CentOS 6.5

먼저 필요 라이브러리 설치

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

wget으로 파이썬 설치파일 다운로드

wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz

xz파일이다. xz 압축을 풀기위해서 xz설치

yum install xz

압축 해제

tar xvfJ Python-2.7.6.tar.xz

폴더 이동.

cd Python-2.7.6.tar.xz

빌드하자

./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make
sudo make altinstall

파이썬 설치 완료

이제 PATH를 확인하자.

env | grep PATH

기본으로 /usr/local/bin이 /usr/bin보다 앞에 나와있다.

기존 파이썬이 설치된 디렉토리로 이동

cd /usr/bin

기존 파이썬 파일명 변경

sudo mv python python.old

리눅스 터미널에 재접속해서 python 2.7이 정상적으로 설치되었는지 확인

python
Python 2.7.6 (default, Apr 27 2015, 17:35:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

ruby rbenv install 2.0.0-p247 fail for Centos

rbenv 를 이용해서 ruby 2.0.0 p247을 설치할 때 에러가 발생한다. centos 6.5에서 발생했다.

해결법을 기록해둔다. 참고가 되길 바란다.

ref web site

rbenv install 2.0.0-p247

위의 명령을 실행했을 때 아래 상황 발생

problem:

BUILD FAILED

Inspect or clean up the working tree at /tmp/ruby-build.20150424111036.5089
Results logged to /tmp/ruby-build.20150424111036.5089.log

Last 10 log lines:
ossl_pkey_ec.c:821: error: for each function it appears in.)
make[2]: *** [ossl_pkey_ec.o] Error 1
make[2]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247/ext/openssl'
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
installing default callback libraries
linking shared-object dl/callback.so
make[2]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247/ext/dl/callback'
make[1]: Leaving directory `/tmp/ruby-build.20150424111036.5089/ruby-2.0.0-p247'
make: *** [build-ext] Error 2

solution:

1. Create “patch.diff” file.
2. Copy the content below.

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41807)
+++ ChangeLog	(revision 41808)
@@ -1,3 +1,16 @@
+Sat Jul  6 07:37:43 2013  Martin Bosslet  <Martin.Bosslet@gmail.com>
+
+	* ext/openssl/ossl_pkey_ec.c: Ensure compatibility to builds of
+	  OpenSSL with OPENSSL_NO_EC2M defined, but OPENSSL_NO_EC not
+	  defined.
+	* test/openssl/test_pkey_ec.rb: Iterate over built-in curves
+	  (and assert their non-emptiness!) instead of hard-coding them, as
+	  this may cause problems with respect to the different availability
+	  of individual curves in individual OpenSSL builds.
+	  [ruby-core:54881] [Bug #8384]
+
+	  Thanks to Vit Ondruch for providing the patch!
+
 Sat Jul  6 07:12:39 2013  Martin Bosslet  <Martin.Bosslet@gmail.com>
 
 	* test/openssl/test_x509crl.rb: Remove unused variable.
Index: ext/openssl/ossl_pkey_ec.c
===================================================================
--- ext/openssl/ossl_pkey_ec.c	(revision 41807)
+++ ext/openssl/ossl_pkey_ec.c	(revision 41808)
@@ -762,8 +762,10 @@
                 method = EC_GFp_mont_method();
             } else if (id == s_GFp_nist) {
                 method = EC_GFp_nist_method();
+#if !defined(OPENSSL_NO_EC2M)
             } else if (id == s_GF2m_simple) {
                 method = EC_GF2m_simple_method();
+#endif
             }
 
             if (method) {
@@ -817,8 +819,10 @@
 
             if (id == s_GFp) {
                 new_curve = EC_GROUP_new_curve_GFp;
+#if !defined(OPENSSL_NO_EC2M)
             } else if (id == s_GF2m) {
                 new_curve = EC_GROUP_new_curve_GF2m;
+#endif
             } else {
                 ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
             }
Index: test/openssl/test_pkey_ec.rb
===================================================================
--- test/openssl/test_pkey_ec.rb	(revision 41807)
+++ test/openssl/test_pkey_ec.rb	(revision 41808)
@@ -7,28 +7,28 @@
     @data1 = 'foo'
     @data2 = 'bar' * 1000 # data too long for DSA sig
 
-    @group1 = OpenSSL::PKey::EC::Group.new('secp112r1')
-    @group2 = OpenSSL::PKey::EC::Group.new('sect163k1')
-    @group3 = OpenSSL::PKey::EC::Group.new('prime256v1')
+    @groups = []
+    @keys = []
 
-    @key1 = OpenSSL::PKey::EC.new
-    @key1.group = @group1
-    @key1.generate_key
+    OpenSSL::PKey::EC.builtin_curves.each do |curve, comment|
+      group = OpenSSL::PKey::EC::Group.new(curve)
 
-    @key2 = OpenSSL::PKey::EC.new(@group2.curve_name)
-    @key2.generate_key
+      key = OpenSSL::PKey::EC.new(group)
+      key.generate_key
 
-    @key3 = OpenSSL::PKey::EC.new(@group3)
-    @key3.generate_key
-
-    @groups = [@group1, @group2, @group3]
-    @keys = [@key1, @key2, @key3]
+      @groups << group
+      @keys << key
+    end
   end
 
   def compare_keys(k1, k2)
     assert_equal(k1.to_pem, k2.to_pem)
   end
 
+  def test_builtin_curves
+    assert(!OpenSSL::PKey::EC.builtin_curves.empty?)
+  end
+
   def test_curve_names
     @groups.each_with_index do |group, idx|
       key = @keys[idx]

3. Create “fedora.configure” file
4. Copy the content below.

#!/bin/sh
patch -p0 -i /tmp/patch.diff
exec ./configure "$@"

5. Execute this command.

RUBY_CONFIGURE=/home/user/fedora-configure rbenv install 2.0.0-p247

6. check ruby version.

rbenv versions