由于centos7原本就安装了Python2,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到。
[root@n5 ~]# which python /usr/bin/python
/usr/bin下面可以看作是一些快捷方式的集合,常用命令的指引+自己创建的软连接
创建软连接:ln -s source target target是快捷方式的路径,source是源文件路径
删除软连接:rm -rf target 注意target后面不能加/,会导致把源文件删除
1.安装依赖包
yum -y groupinstall "Development tools" yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2.下载python(要用pandas的话千万要装3.5以上版本的)
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
3.安装
mkdir /usr/local/python3
tar -xvJf Python-3.6.4.tar.xz
mv Python-3.6.4/* /usr/local/python3
cd /usr/local/python3
./configure --prefix=/usr/local/python3
make && make install
4.创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.安装ipython
pip3 install ipython
ln -s /usr/local/python3/bin/ipython3 /usr/bin/ipython3
6.pip的一些包
pip3 install numpy #矩阵计算 pip3 install pandas #数据分析 pip3 install scipy #线性代数+优化 pip3 install matplotlib pip3 install -U nltk #nltp pip3 install -U scikit-learn #ML库
pip3 install sklearn
pip3 install jieba
pip3 install ipdb #用来调试
pip3 install tqdm #可视化进度
pip3 install fire #自动生成命令行,能把自己写的函数变成命令
# 装tensorflow pip3 install np_utils pip3 install keras pip3 install tensorflow pip3 install future # from __future__ import absolute_import