linux安装python并安装pip
因为最近要在linux环境下进行python编程,所以就试着去安装了一下,但是网上关于python以及pip的安装说实话有点混乱,所以我今天就把前辈的经验再次总结一下,希望可以给大家提供帮助。
python源码包的下载:
https://www.python.org/downloads/
安装python 可能出问题 ImportError: cannot import name HTTPSHandler ImportError: No module named setuptools 前期的准备,防止出现上面的问题 yum -y install zlib yum -y install zlib-devel yum install gcc-c++ 安装所需要的编译器 yum install openssl -y yum install openssl-devel -y 解压安装python tar -zxvf Python-2.7.13.tgz cd Python-2.7.13 ./configure --prefix=/usr/local/Python2.7 make && make install 更新编译器 rm /usr/bin/python ln -s /usr/local/Python2.7/bin/python /usr/bin/python vim /usr/bin/yum 第一行修改成#!/usr/bin/python2.6 创建库文件,并且刷新库文件 方案一: cd /etc/ld.so.conf.d/ vim python2.7.conf /usr/local/Python2.7/lib ldconfig 方案二: cd /etc/ld.so.conf.d/ echo '/usr/local/Python2.7/lib'> python2.7.conf 安装setuptools以便于后面的pip安装 # wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz --no-check-certificate # tar zxvf setuptools-2.0.tar.gz # cd setuptools-2.0 # python setup.py build # python setup.py install 安装pip # wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate # tar -xzvf pip-1.5.4.tar.gz # cd pip-1.5.4 # python setup.py install
安装完成 测试pip
pip install nose
参考博文:
http://blog.csdn.net/u013372487/article/details/51726002
http://blog.csdn.net/yabingshi_tech/article/details/50439142