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.

Space in filename in PIP_CONSTRAINTS is interpreted as a new file

See original GitHub issue

Description

The PIP_CONSTRAINTS variable (and likely any other path related variables?) can’t handle a path with a space in it. Something like PIP_CONSTRAINTS="C:\Program Files\..." causes Could not open requirements file: [Errno 2] No such file or directory: 'C:\\Program'. These path variables should probably interpret spaces as part of paths, and use a separator for multiple values (like : or ;).

Also, quotes around the path causes this to fail, too, PIP_CONSTRAINTS="'C:\Program Files\...'" breaks.

See https://github.com/pypa/cibuildwheel/issues/740

Expected behavior

Spaces in paths should not break.

pip version

21.1.3

Python version

All

OS

Windows and macOS, at least, probably all.

How to Reproduce

  1. Make a constraints file with a space my constraints.txt
  2. Then run PIP_CONSTRAINTS="my constraints.txt" pip install <package>
  3. An error occurs.

Output

Could not open requirements file: [Errno 2] No such file or directory: 'C:\\Program'`

Code of Conduct

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Jun 30, 2021

I believe since 10.0 the : path separator is purely cosmetic on macOS; it always stores paths with /, and only transforms it to : when showing it in GUI. So as far as Python code (which is run in POSIX mode) is concerned, we can use os.pathsep without issues.

But there are two major downsides here. First, this means the accepted values on POSIX and Windows will be different (os.pathsep is ; on Windows), which will cause user confusion. Another is that most of pip’s path arguments are actually path-or-URL (including PIP_CONSTRAINT!) and obviously you’re going you run into issues parsing /a/local/path:https://rawgithubcontent.com/pypa/pip/requirements.txt. So I think the quoting + space solution is the way to go if we want to do this.

1reaction
pfmoorecommented, Jun 30, 2021

Ah, I didn’t know MacOS did that. Cross-platform rules are weird 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip3 fails to install python module with space in name from ...
PyPI packages cannot have spaces in the name. There is no package named jupyter qtconsole , and no way to search for one...
Read more >
Requirements File Format - pip documentation v22.3.1
Requirements files serve as a list of items to be installed by pip, when using pip install. Files that use this format are...
Read more >
User Guide — pip 10.0.0.dev0 documentation
Constraints files are requirements files that only control which version of a requirement is installed, not whether it is installed or not. Their...
Read more >
Pip constraints files - Blog | luminousmen
In python, it is common practice to write all the application dependencies that are installed via pip into a separate text file.
Read more >
pip Documentation - Read the Docs
This means pip works on the latest patch version of each of these minor ... Including a package in a constraints file does...
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