CentOS 6.9 安裝python2.7

CentOS 6.9 安裝python2.7

yum groupinstall “Development tools”

tar -zxvf Python-2.7.12.tgz
cd Python-2.7.12/
./configure –prefix=/usr/local –enable-optimizations
make && make altinstall
//找出python
which python

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”
python get-pip.py

pip install jieba
pip install gensim

yum install perl-CPAN

yum install python-setuptools python-setuptools-devel
yum install gcc-c++

cpan YAML
cpan Module::Build #這段常出錯
若是失敗
*yum install perl-ExtUtils-MakeMaker
* cpan Module::Install

上面兩個不確定要不要用 但莫名好了

cpan force install Module::Build

問題 build-essential
yum install -y libxml2 libxml2-devel libxslt libxslt-devel

1. Can’t locate Encode/Detect/Detector.pm 問題解決

wget http://search.cpan.org/CPAN/authors/id/J/JG/JGMYERS/Encode-Detect-1.00.tar.gz
tar -zxvf Encode-Detect-1.00.tar.gz
cd Encode-Detect-1.00
vi parche

—–新增內容—-
— Detector.xs 2006-10-27 16:48:59.000000000 -0400
+++ Detector.xs.old 2008-04-29 15:59:43.000000000 -0400
@@ -38,6 +38,7 @@
#define PERL_NO_GET_CONTEXT /* we want efficiency */
#include “EXTERN.h”
#include “perl.h”
+#undef HASATTRIBUTE_UNUSED
#include “XSUB.h”
}
——內容結束—-

perl Makefile.PL && make && make install