卸载python
卸载python3.6及其所有依赖。如需卸载其它系统程序,也可使用如下命令,如卸载dnf或者yum,卸载完成后重新键入dnf或者yum即可。(本人就是卸载python失误后,dnf和yum全部失效的受害者T_T,折腾了好半天才修复,千万不要乱删系统环境的python,由于高版本的dnf和yum依赖于python环境,所以删除python一定要用下面的方法,不然会很麻烦。)
[root@cvallis rpm]# rpm -qa python3 # 查看python
[root@cvallis rpm]# rpm -qa | grep python3 | xargs rpm -e --nodeps #这一步一定要执行,而且要将所有的组件卸载掉,如果卸载不干净,后面安装会有问题
安装python
在命令行中键入python3.7,系统会提示安装
[root@cvallis rpm]# python3.7
bash: python3.7: command not found...
Install package 'python37' to provide command 'python3.7'? [N/y] y
* Waiting in queue...
The following packages have to be installed:
python37-3.7.0-1.fc28.x86_64 Version 3.7 of the Python interpreter
tk-1:8.6.8-1.fc28.x86_64 The graphical toolkit for the Tcl scripting language
Proceed with changes? [N/y] y
* Waiting in queue...
* Waiting for authentication...
* Waiting in queue...
* Downloading packages...
* Requesting data...
* Testing changes...
* Installing packages...
设为默认python
[root@cvallis Downloads]# rm -rf /usr/bin/python
[root@cvallis Downloads]# ln -s /usr/bin/python3.7 /usr/bin/python
安装setuptools
源码安装:
需要先下载setuptools源码,然后cd进去。[setuptools下载链接]
[root@cvallis Downloads]# cd setuptools-40.0.0/
[root@cvallis Downloads]# python setup.py build
[root@cvallis Downloads]# python setup.py install
如果提示如下报错,就建立提示路径/usr/local/lib/python3.7/site-packages
[root@cvallis setuptools-40.0.0]# python setup.py install
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 2] No such file or directory: '/usr/local/lib/python3.7/site-packages/test-easy-install-22777.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python3.7/site-packages/
安装pip
需要先下载pip源码,然后cid进去。[pip源码下载连接]
[lay@cvallis pip-8.0.2]# sudo python setup.py bulid
[lay@cvallis pip-8.0.2]# sudo python setup.py install
升级一下pip
[lay@cvallis pip-8.0.2]# pip install --upgrade pip
安装系统rpm包
163镜像源[fedroa28 workstation]
–replacepkgs 重新安装
–force 强制安装
–nodeps 忽略依赖关系:副作用:安装成功,但未必能够成功运行
[lay@cvallis pip-8.0.2]# rpm -ivh dnf-2.7.5-12.fc28.noarch.rpm
也可将现在好的rpm包放入新建文件夹,如rpm文件夹,然后使用下面命令,即安装以dnf-开头的文件(正则表达式而以)
[lay@cvallis rpm]# rpm -ivh dnf-*