question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip uninstall fails when console-scripts stubs include upper case characters

See original GitHub issue
  • Pip version: 8.1.2
  • Python version: 3.5.1
  • Operating System: OS X 10.11.5

Description:

If I define a console-scripts stub with upper case characters it installs fine but when I come to uninstall (with ‘pip uninstall <package>’), I get a FileNotFound exception because it has lower-cased the filename.

What I’ve run:

In setup.py I have the following which defines a stub with filename myScript:

entry_points={ 'console_scripts': ['myScript=mypackage:mymodule:main'] },

…and then when I uninstall I get the error:

Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 538, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.5/bin/myscript' -> '/var/folders/b7/21c2x2g57nj4twr97bzb1rp5cw85hb/T/pip-8g3gry4t-uninstall/Library/Frameworks/Python.framework/Versions/3.5/bin/myscript'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/commands/uninstall.py", line 76, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/req/req_set.py", line 336, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 552, in move
    copy_function(src, real_dst)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 251, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/Library/Frameworks/Python.framework/Versions/3.5/bin/myscript'

The above output shows that something has lowercased the filename before trying to delete the file. Do we need a similar fix to that that was done here: #3324 ?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
michael-sanderscommented, Jun 16, 2016

@ed11s8c If you use setup.py to install (rather than pip) then what you’re seeing is a known issue:

$ pip help uninstall

Usage:
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

Description:
  Uninstall packages.

  pip is able to uninstall most installed packages. Known exceptions are:

  - Pure distutils packages installed with ``python setup.py install``, which
    leave behind no metadata to determine what files were installed.
  - Script wrappers installed by ``python setup.py develop``.
0reactions
NathanDunfieldcommented, Aug 18, 2018

I just tested in the same manner as my comment above (on macOS 10.12 with Pythons 2.7. 3.5, and 3.6), and this problem went away in pip 10 and is not present in pip 18. So I think this ticket may safely be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2037702 – Python doesn't pip-uninstall distutils-installed console ...
Description of problem: Packages installed with (sudo) setup.py and uninstalled with (sudo) pip leave stray console scripts in /usr/local/bin.
Read more >
History - setuptools 65.6.3.post20221216 documentation
Setuptools will adopt the name of the top-level package (or module in the case of single-module distributions), only when name is not explicitly...
Read more >
pytest Documentation - Read the Docs
How to re-run failed tests and maintain state between test runs . ... If this is the case you have two options:.
Read more >
Python Entry point 'console_scripts' not found - Stack Overflow
I tried to pip uninstall , but the problem was still there;. What solved the issue in my case was: Remove manually every...
Read more >
Text - Python mailing list
In the best case, when the caches exist and you trust them, loading them would ... It looks like the characters are mostly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found