# 安装python
* * * * *
* 建议使用 python2.7
* 参考大神:[廖雪峰Python教程](https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000)
>[info] 1.window下载安装
* [官方下载](https://www.python.org/downloads/)
>[info] 2.mac,linux 安装
* 一般自带,如果没有官方下载即可
>[info] 3.升级为2.7版本
* 下载源码
~~~
wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
tar zxvf Python-2.7.14.tgz
cd Python-2.7.14.tgz
./configure --prefix=/usr/local/python27
make && make install
~~~
* 替换旧版本
~~~
which python
mv /usr/bin/python /usr/bin/python26
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
~~~
* 错误解决
~~~
python 报错的话:
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
# 原因:linux系统默认没有把/usr/local/python27/lib路径加入动态库搜索路径
~~~
* 加入动态库
~~~
[root@vip ~]# vim /etc/ld.so.conf
# 添加如下一行内容
/usr/local/python27/lib
[root@vip ~]# ldconfig # 使新添加的路径生效
~~~
* 升级 python 后,安装 pip 工具
1. 下载安装
~~~
[root@vip ~]# wget https://bootstrap.pypa.io/get-pip.py
[root@vip ~]# python get-pip.py
~~~
2. 设置软连接
~~~
[root@vip ~]# ln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip
~~~
* 安装 ipython
~~~
[root@vip ~]# pip install ipython==1.2.1
[root@vip ~]# ln -s /usr/local/python27/bin/ipython /usr/bin/ipython
~~~