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.

File encoding issue in _install_wheel (pip 20.2, python 2)

See original GitHub issue

Environment

  • pip version: 20.2
  • Python version: 2.7
  • OS: linux

Description

pip install mr.bob fails with pip 20.2:

Processing /home/sbi-local/.cache/pip/wheels/d3/64/58/cd7b9ff05f450397981fa37a0a279ed1d12cf763af16d8d7d7/mr.bob-0.1.2-py2-none-any.whl
Requirement already satisfied: Jinja2>=2.5.0 in /home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages (from mr.bob) (2.11.2)
Requirement already satisfied: six>=1.2.0 in /home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages (from mr.bob) (1.15.0)
Requirement already satisfied: setuptools in /home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages (from mr.bob) (44.1.1)
Requirement already satisfied: MarkupSafe>=0.23 in /home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages (from Jinja2>=2.5.0->mr.bob) (1.1.1)
Installing collected packages: mr.bob
ERROR: Exception:
Traceback (most recent call last):
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
    status = self.run(options, args)
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
    return func(self, options, args)
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 421, in run
    pycompile=options.compile,
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/req/__init__.py", line 90, in install_given_reqs
    pycompile=pycompile,
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/req/req_install.py", line 831, in install
    requested=self.user_supplied,
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/operations/install/wheel.py", line 829, in install_wheel
    requested=requested,
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/operations/install/wheel.py", line 658, in _install_wheel
    file.save()
  File "/home/sbi-local/.virtualenvs/tempenv-7d78147760d35/lib/python2.7/site-packages/pip/_internal/operations/install/wheel.py", line 442, in save
    with self._zip_file.open(self.src_record_path) as f:
  File "/usr/lib/python2.7/zipfile.py", line 984, in open
    zinfo = self.getinfo(name)
  File "/usr/lib/python2.7/zipfile.py", line 932, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named u'mrbob/tests/templates/encodingc\\u030c/mapc\\u030ca/c\\u0301a.bob' in the archive"

I’ve not had time to investigate if that error comes from a bug in that old package or is a bug in the new _install_wheel. It works fine with pip 20.1 though, as well as with pip 20.2 on python 3.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Aug 2, 2020

This sounds like a hairy topic. Quoting Python 2 documentation on zipfile:

There is no official file name encoding for ZIP files. If you have unicode file names, you must convert them to byte strings in your desired encoding before passing them to write(). WinZip interprets all file names as encoded in CP437, also known as DOS Latin.

So I guess there is no “correct” way here. Python 3 detects UTF-8 support with a header flag. I’m not familiar with the ZIP spec to comment on the approach, and would assume it’s the best we can do.

0reactions
uranusjrcommented, Aug 3, 2020

I update #8684 to always assume UTF-8 instead. This should be quite straightforward now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix errors occurring on installation of Jupyter Notebook
I solved the problem by installing python on its 64-bit version. ... missing of wheel, try to download it: python.exe pip install wheel...
Read more >
User Guide - pip documentation v22.3.1
pip supports installing from PyPI, version control, local projects, and directly from distribution files. The most common scenario is to install from PyPI...
Read more >
urllib3
HTTP library with thread-safe connection pooling, file post, and more. ... File uploads with multipart encoding. ... python -m pip install urllib3.
Read more >
User Guide - pip documentation v21.1.dev0
Support for percent-encoded authentication in index URLs was added in pip ... python -m pip install wheel python -m pip wheel --wheel-dir=/local/wheels -r ......
Read more >
Python 2.7 — pip issue installing almost any library
So, I installed Python2 and setup my virtualenv whith python 2 ... wheels are ZIP archives with a specially formatted file name and...
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