Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For a cloned environment: UnicodeDecodeError: Invalid start byte in METADATA file #10839

Closed
1 task done
SRJaffry opened this issue Jan 29, 2022 · 3 comments
Closed
1 task done
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality

Comments

@SRJaffry
Copy link

SRJaffry commented Jan 29, 2022

Description

Hi,

pip commands, such as 'pip list' is giving errors such that they are unable to read certain files.
When I dug into the issue, the files had gibberish data into them. The same command is working fine the root environment.

Following is the error when I ran pip list (for example):

> 
> ERROR: Exception:
> Traceback (most recent call last):
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
>     status = self.run(options, args)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 179, in run
>     self.output_package_listing(packages, options)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 255, in output_package_listing
>     data, header = format_for_columns(packages, options)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 307, in format_for_columns
>     row = [proj.raw_name, str(proj.version)]
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\metadata\base.py", line 163, in raw_name
>     return self.metadata.get("Name", self.canonical_name)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\metadata\pkg_resources.py", line 96, in metadata
>     return get_metadata(self._dist)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\utils\packaging.py", line 48, in get_metadata
>     metadata = dist.get_metadata(metadata_name)
>   File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1424, in get_metadata
>     return value.decode('utf-8')
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 14097: invalid start byte in METADATA file at path: c:\users\shan_jaffry\miniconda3\lib\site-packages\hupper-1.10.2.dist-info\METADATA
> 

When I open the file, it actually had the gibberish at the very end.

0.2 (2016-10-26)

  • Windows support!

  • Added support for watchdog <https://pypi.org/project/watchdog/>_ if it's
    installed to do inotify-style file monitoring. This is an optional dependency
    and hupper will fallback to using polling if it's not available.

0.1 (2016-10-21)

  • Initial rele9ýl�·øA

Expected behavior

commands with pip should run smoothly, such as 'pip list'.
Commands such as pip --version are working fine.

pip version

21.2.4

Python version

3.9

OS

Windows

How to Reproduce

pip list

Output

ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 179, in run
    self.output_package_listing(packages, options)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 255, in output_package_listing
    data, header = format_for_columns(packages, options)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\commands\list.py", line 307, in format_for_columns
    row = [proj.raw_name, str(proj.version)]
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\metadata\base.py", line 163, in raw_name
    return self.metadata.get("Name", self.canonical_name)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\metadata\pkg_resources.py", line 96, in metadata
    return get_metadata(self._dist)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_internal\utils\packaging.py", line 48, in get_metadata
    metadata = dist.get_metadata(metadata_name)
  File "C:\Users\shan_jaffry\Miniconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1424, in get_metadata
    return value.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 14097: invalid start byte in METADATA file at path: c:\users\shan_jaffry\miniconda3\lib\site-packages\hupper-1.10.2.dist-info\METADATA

Code of Conduct

@SRJaffry SRJaffry added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Jan 29, 2022
@pradyunsg
Copy link
Member

Sadly, in situations like this, pip can't really "just work" like you're hoping since there's no real way to read this file for pip. And reading this file is necessary for parsing the version.

What we can do is provide a clearer error message, so I'll mark this issue for that.

@pradyunsg pradyunsg added C: error messages Improving error messages type: enhancement Improvements to functionality and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Jan 29, 2022
@Shivansh-007
Copy link
Contributor

Hey, @SRJaffry could you provide a better reproducer, I tried reproducing the "bug" with pip==21.2.4 and hupper=1.10.2 but I couldn't reproduce it, there were no undecodable bytes at the end of the METADATA file of hupper.

Screenshot from 2022-03-12 22-20-57

I tried injecting them manually at the end of the file, but that didn't work either.

@pradyunsg pradyunsg added the S: awaiting response Waiting for a response/more information label Mar 13, 2022
@pradyunsg pradyunsg changed the title For a cloned environemnt: UnicodeDecodeError: Invalid start byte in MERADATA file For a cloned environment: UnicodeDecodeError: Invalid start byte in MERADATA file Mar 26, 2022
@pradyunsg pradyunsg changed the title For a cloned environment: UnicodeDecodeError: Invalid start byte in MERADATA file For a cloned environment: UnicodeDecodeError: Invalid start byte in METADATA file Mar 26, 2022
@pradyunsg
Copy link
Member

Closing due to lack fo a response here.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2022
@pradyunsg pradyunsg removed the S: awaiting response Waiting for a response/more information label Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: error messages Improving error messages type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

3 participants