Linux非root用户安装Python及相关库

前提准备工作,通过root安装
yum install -y tkinter tk-devel gcc


下面是普通用户操作(用户lilei)

1、安装python
python版本库https://www.python.org/ftp/python/,此处我选择2.7.9版本的,在安装python的时候,使用--prefix指定安装路径即可,命令如下:
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -xzf Python-2.7.9.tgz
cd Python-2.7.9
mkdir -p /home/lilei/software/python27
./configure --prefix="/home/lilei/software/python27"
make
make install

2、安装setuptools
setuptools主要是为安装pip做准备的,下面是从下载到安装的全部命令,使用上面安装的指定路径的python
/home/lilie/software/python27/bin/python进行安装:
wget --no-check-certificate http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
tar -xzvf setuptools-2.0.tar.gz
cd setuptools-2.0
/home/lilei/software/python27/bin/python setup.py install

3、安装pip
使用pip来安装python相关库,方便简单,此处将python setup.py install的python换成自己安装的指定路径python
/home/lilie/software/python27/bin/python setup.py install.
wget --no-check-certificate https://pypi.python.org/packages/41/27/9a8d24e1b55bd8c85e4d022da2922cb206f183e2d18fee4e320c9547e751/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
tar -xzf pip-8.1.1.tar.gz
cd pip-8.1.1
/home/lilei/software/python27/bin/python setup.py install

4、安装相关库
进入python安装目录的bin路径下,安装下面相关库,经测试,下列库均可安装。
simplejson
redis
numpy
scipy
sklearn
matplotlib

安装命令:
cd /home/lilei/software/python27/bin/
./pip install simplejson
./pip install redis
./pip install numpy
./pip install scipy
./pip install sklearn
./pip install matplotlib

参考:http://blog.csdn.net/dream_angel_z/article/details/51338546

你可能感兴趣的:(Python)