Skip to content

Parsing Error when requirements.txt Has UTF-16 Encoding #1393

@pydsigner

Description

@pydsigner

Environment

  • deptry version: 0.24.0
  • Python version: 3.13.2
  • Operating system: Windows 11

Describe the issue

When a requirements.txt file has a UTF-16 encoding, deptry is not able to parse the file, though pip can still use it.

packaging.requirements.InvalidRequirement: Expected package name at the start of dependency specifier
    ÿþdeptry

Notice the BOM characters appearing in the traceback.

Minimal way to reproduce the issue

Create a requirements.txt file, put deptry in it, and give it a UTF-16 encoding. I made my test file in VS Code using the encoding menu.

Expected behavior

Deptry is able to parse the file and evaluate the dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions