python删除安装的模块
上篇讲述了如何用distutils模块来创建分发包,那么安装了模块之后,怎么来删除呢,具体的步骤如下:
[root@FTP ansible]# ls -l /usr/share/kel -rw-r--r-- 1 root root 86 May 9 09:23 /usr/share/kel [root@FTP ansible]# python setup.py install --record install.txt running install running build running build_py creating build creating build/lib creating build/lib/ansible copying lib/ansible/__init__.py -> build/lib/ansible running build_scripts creating build/scripts-2.7 copying and adjusting bin/ansible -> build/scripts-2.7 changing mode of build/scripts-2.7/ansible from 644 to 755 running install_lib copying build/lib/ansible/__init__.py -> /usr/local/python/lib/python2.7/site-packages/ansible byte-compiling /usr/local/python/lib/python2.7/site-packages/ansible/__init__.py to __init__.pyc running install_scripts copying build/scripts-2.7/ansible -> /usr/local/python/bin changing mode of /usr/local/python/bin/ansible to 755 running install_data running install_egg_info Removing /usr/local/python/lib/python2.7/site-packages/ansible-1.0-py2.7.egg-info Writing /usr/local/python/lib/python2.7/site-packages/ansible-1.0-py2.7.egg-info writing list of installed files to 'install.txt' [root@FTP ansible]# cat install.txt |xargs rm -rf [root@FTP ansible]# ls -l /usr/share/kel ls: cannot access /usr/share/kel: No such file or directory1、 找到安装文件setup.py,运行并记录,命令如下:
python setup.py install --record install.txt
2、执行删除
cat install.txt |xargs rm -rf
然后就会发现,安装的相关模块已经被删除。
[root@FTP ansible]# cat install.txt /usr/local/python/lib/python2.7/site-packages/ansible/__init__.py /usr/local/python/lib/python2.7/site-packages/ansible/__init__.pyc /usr/local/python/bin/ansible /usr/share/kel /usr/local/python/lib/python2.7/site-packages/ansible-1.0-py2.7.egg-info
打开install.txt,发现其中都是安装的位置和文件,从而执行删除,即可将相应的模块进行删除。
for linux and python