pip: pip fails to install projects with console entry points on Python 3.6

  • Pip version: 8.1.2
  • Python version: 3.6b0
  • Operating System: Windows 7
>py -m pip --version
pip 8.1.2 from C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages (python 3.6)

Description:

This appears to happen for any package with console entry points, but not for packages without. It looks like a distlib bug, so it will need fixing there and revendoring.

Further note, this issue seems to affect python -m pip install -U pip so we’ll need to consider how to help users to upgrade past this issue. (Simplest way may be to recommend that users uninstall pip and then use get-pip.py).

What I’ve run:

>py -m pip install invoke
Collecting invoke
  Using cached invoke-0.13.0-py3-none-any.whl
Installing collected packages: invoke
Exception:
Traceback (most recent call last):
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\commands\install.py", line 317, in run
    prefix=options.prefix_path,
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_set.py", line 742, in install
    **kwargs
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\req\req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\wheel.py", line 493, in move_wheel_files
    maker.make_multiple(['%s = %s' % kv for kv in console.items()])
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 383, in make_multiple
    filenames.extend(self.make(specification, options))
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 372, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 276, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 212, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\scripts.py", line 351, in _get_launcher
    result = finder(distlib_package).find(name).bytes
  File "C:\Users\UK03306\AppData\Local\Programs\Python\Python36\lib\site-packages\pip\_vendor\distlib\resources.py", line 324, in finder
    raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'

Presumably this is distlib issue https://bitbucket.org/pypa/distlib/issues/87/resource-finder-looking-at-wrong-module - is that correct @zooba?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 29 (22 by maintainers)

Commits related to this issue

Most upvoted comments

@ghostsquad The bug was in pip prior to 9.0.1. Your virtual environment has pip 7.1.0, which includes the bug, and so it’s nothing to do with Python 3.6.

You should either recreate your virtual environment, or delete the pip installation from site-packages completely (I’ve found that pip uninstall pip doesn’t work reliably once you’ve failed to upgrade it) and use the get-pip.py script to install it again.

As above, but fixed by running easy_install pip after removing all traces of pip from my venv.

I quickly created a bash script to generate patched venvs on Windows using the information from above. Hope this helps someone generate their venvs a little bit faster!

I chucked it in a Gist

Code inline here:

#!/bin/bash

# This is a handy script to apply a pip fix to the venv created by python 3.6 on Windows
# Written by Mike Goodfellow in a few minutes - feel free to improve this!!
# Based on information in https://github.com/pypa/pip/issues/3964
#
# NOTE: Currently works if python on path points to python3 which is commonly
#       does on Windows.

if [ $# -ne 1 ]
then
	echo "Usage: venv_init /path/to/venv"
	exit 1
fi

echo "Creating new venv in $1..."

# NOTE: This needs to be on the path...
python -m venv $1

echo "Applying the pip fix..."

rm -rf $1/Lib/site-packages/pip*

$1/Scripts/easy_install pip

$1/Scripts/pip install --upgrade pip setuptools

echo "Patched version of venv has been configured in $1"

Written in 5 mins, so feel free to improve

Same problem here on Windows 10: fresh Python 3.6 install, fresh venv.

(venv-3.6) C:\Users\Myuser\Documents>python -m pip install --upgrade pip
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 7.1.0
	Uninstalling pip-7.1.0:
	  Successfully uninstalled pip-7.1.0
  Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\basecommand.py", line 223, in main
	status = self.run(options, args)
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\commands\install.py", line 299, in run
	root=options.root_path,
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\req\req_set.py", line 646, in install
	**kwargs
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\req\req_install.py", line 813, in install
	self.move_wheel_files(self.source_dir, root=root)
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\req\req_install.py", line 1008, in move_wheel_files
	isolated=self.isolated,
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\wheel.py", line 449, in move_wheel_files
	generated.extend(maker.make(spec))
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\_vendor\distlib\scripts.py", line 323, in make
	self._make_script(entry, filenames, options=options)
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\_vendor\distlib\scripts.py", line 227, in _make_script
	self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\_vendor\distlib\scripts.py", line 163, in _write_script
	launcher = self._get_launcher('t')
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
	result = finder(distlib_package).find(name).bytes
  File "C:\Users\Myuser\venv-3.6\lib\site-packages\pip\_vendor\distlib\resources.py", line 297, in finder
	raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'


(venv-3.6) C:\Users\Myuser\Documents>

Fixed by deleting all pip related directories under C:\Users\Myuser\venv-3.6\Lib\site-packages\, downloading get-pip.py and executing the command, as mentioned above by @zooba .

@brettcannon Yeah, we didn’t get the newer version into b3, and the error comes from the installed version, not the one being installed. (However, uninstall followed by get-pip.py should be fine now, I’d imagine.)

We’ll need @vsajip to release a new version of distlib, which we can then vendor. I’m happy to do the re-vendor but I can’t produce a pip release. @dstufft would we be able to do a quick pip release for this?

Without an easy way to disable scripts, allowing an upgrade, maybe this would be worth a fixed Python 3.6b1 Windows binary with the updated pip in it? Unfortunately, that wouldn’t just be the distlib fix, so it may not be a good idea to have pip different in the Linux and Windows builds.