5 <title>setup.py uninstall
</title>
6 <link rel=
"stylesheet" href=
"/css/main.css">
7 <link rel=
"shortcut icon" href=
"/assets/favicon.png" />
8 <meta name=
"description" content=
"Ian Kelling's personal site and blog on software">
9 <link rel=
"canonical" href=
"https://iankelling.org//technical-notes/setup.py-uninstall.html">
11 <meta name=
"viewport" content=
"width=device-width, initial-scale=1">
14 <header class=
"page_header">
15 <h3><a href=
"/">iankelling.org
</a> /
<a href=
"/technical-notes.html">technical notes
</a> /
</h3>
17 <div class=
"main-content-stripe">
19 <h1>setup.py uninstall
</h1><b>Contents
</b><ul>
21 <a href=
"#unix-like">Unix-like
</a>
24 <a href=
"#windows">Windows
</a>
27 <a href=
"#use-other-methods-which-fully-support-uninstall-when-available">Use other methods which fully support uninstall when available
</a>
30 <h2 id=
"unix-like">Unix-like
</h2>
32 <p>Install over the existing installation with the same sources, recording installed files, then delete them.
</p>
33 <div class=
"highlight"><pre><span></span>sudo python setup.py install --record files.txt
34 <span class=
"c1"># inspect files.txt to make sure it looks ok. Then in bash:
</span>
35 tr
<span class=
"s1">'\n
'</span> <span class=
"s1">'\
0'</span> < files.txt
<span class=
"p">|
</span> xargs -
0 sudo rm -f --
37 <h2 id=
"windows">Windows
</h2>
39 <p>Install on top of the existing installation with a windows installer, then add-remove programs to uninstall.
</p>
40 <div class=
"highlight"><pre><span></span>python setup.py bdist_wininst
41 dist/foo-
1.0.win32.exe
43 <h2 id=
"use-other-methods-which-fully-support-uninstall-when-available">Use other methods which fully support uninstall when available
</h2>
45 <p>Uninstalling setup.py install has some
<em>inherent problems
</em>, which usually aren
't a problem:
</p>
48 <li>Files which a different package also depends on will be removed by uninstall
</li>
49 <li>Can
't remove installed directories. --record only records non-directory files.
</li>
50 <li>If a file is installed which includes a newline, the command this page
51 recommends will fail. This won
't happen except for a rare bug or a
52 malicious program. We could overcome this by using bdist_dumb, then
53 removing the files found in the archive which that command
54 builds. However, I
'm no more confident of that command not having a
55 bug or edge case in which it would produce different files than a
56 normal install than I am of a package having a file with a newline in
60 <h3 id=
"alternatives">Alternatives
</h3>
64 <li>python setup.py install bdist_rpm
</li>
65 <li>python setup.py bdist_wininst
</li>
66 <li><a href=
"https://packaging.python.org/">official python recommendations
</a></li>
69 <p>This page is also at
<a href=
"http://stackoverflow.com/a/25209129/14456">stackoverflow answer
</a>.
</p>
71 <p>TODO: contribute this under https://wiki.python.org/moin/Distutils/Cookbook.
</p>
75 <div class=
"comment-stripe">
80 <p>Sources in
<a href=
"/git/?p=iankelling.org;a=summary">git
</a>. Mostly markdown files. Default is
<a rel=
"license" href=
"http://creativecommons.org/licenses/by-sa/4.0/"><img class=
"cc-by-sa" alt=
"Creative Commons License" src=
"/assets/cc-by-sa-4.0-80x15.png" /></a></p>
81 <p><address><a href=
"mailto:ian@iankelling.org">ian@iankelling.org
</a> let me know what you think
</address></p>