linux下centos6.10搭建py2.7版本
1、下载python
在/usr/local下执行wget https://www.python.org/ftp/python/2.7.7/Python-2.7.7.tgz
2、解压、编译安装(依次执行以下5条命令)
tar -zxvf Python-2.7.7.tgz
cd Python-2.7.7
./configure --prefix=/usr/local/python-2.7.7
make
make install
3、为python2.7添加软链接:
ln -s /usr/local/python-2.7.7/bin/python /usr/bin/python2
验证是否成功:

4、为pip添加软链接:
在cd /usr/local/bin目录下

使用软链接:ln -s 源文件 目标文件
ln -s /usr/local/bin/pip2.7 /usr/bin/pip
[aam@Adfuser1-1 bin]$ ln -s /usr/local/bin/pip2.7 /usr/bin/pip ln: creating symbolic link `/usr/bin/pip': File exists [aam@Adfuser1-1 bin]$ rm -rf /usr/bin/pip rm: cannot remove `/usr/bin/pip': Permission denied [aam@Adfuser1-1 bin]$ sudo rm -rf /usr/bin/pip [aam@Adfuser1-1 bin]$ ln -s /usr/local/bin/pip2.7 /usr/bin/pip ln: creating symbolic link `/usr/bin/pip': Permission denied [aam@Adfuser1-1 bin]$ sudo ln -s /usr/local/bin/pip2.7 /usr/bin/pip [aam@Adfuser1-1 bin]$ pip Usage: pip <command> [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. check Verify installed packages have compatible dependencies. config Manage local and global configuration.
验证是否成功,到根目录,直接执行pip list
[root@Adfuser1-1 ~]# pip list Package Version ---------- ------- pip 19.3.1 setuptools 42.0.2 wheel 0.33.6 The repository located at mirrors.cloud.aliyuncs.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.cloud.aliyuncs.com'. [root@Adfuser1-1 ~]#
善于跌倒仍喜爱奔跑~

浙公网安备 33010602011771号