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

FileNotFoundError: [Errno 2] No such file or directory on _IMPORT_CWD = os.path.abspath(os.getcwd()) #11036

Closed
1 task done
flatsiedatsie opened this issue Apr 14, 2022 · 4 comments
Labels
project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior

Comments

@flatsiedatsie
Copy link

Description

I'm not sure what happened, but I couldn't find any issues that mentioned something similar (except for maybe this one?), so I thought I'd share, just in case.

$ pip list --outdated
Traceback (most recent call last):
  File "/home/pi/.local/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/configuration.py", line 20, in <module>
    from pip._internal.exceptions import (
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/exceptions.py", line 14, in <module>
    from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/__init__.py", line 16, in <module>
    _IMPORT_CWD = os.path.abspath(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory

$ pip3 list --outdated
Traceback (most recent call last):
  File "/home/pi/.local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/configuration.py", line 20, in <module>
    from pip._internal.exceptions import (
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/exceptions.py", line 14, in <module>
    from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/__init__.py", line 16, in <module>
    _IMPORT_CWD = os.path.abspath(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory

$ pip3 -V
Traceback (most recent call last):
  File "/home/pi/.local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/configuration.py", line 20, in <module>
    from pip._internal.exceptions import (
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_internal/exceptions.py", line 14, in <module>
    from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
  File "/home/pi/.local/lib/python3.9/site-packages/pip/_vendor/rich/__init__.py", line 16, in <module>
    _IMPORT_CWD = os.path.abspath(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory

I solved the problem with a complete reinstall of Pip using

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

Feel free to close if silly

Expected behavior

I expected pip3 to work. I could have sworn it worked fine the other day.

pip version

Unknown

Python version

3.9.2

OS

Raspberry Pi OS Bullseye, 32bit, Linux pi 5.10.103-v7+ #1529 SMP armv7l GNU/Linux

How to Reproduce

I do not know, it came out of nowhere.

Output

No response

Code of Conduct

@flatsiedatsie flatsiedatsie added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 14, 2022
@asottile
Copy link
Contributor

this is a regression due to the introduction of rich in 22.0.4 -- it should probably be reported to the rich bug tracker as well:

set -euxo pipefail
pip="$PWD/venv/bin/pip"
"$pip" install pip=="$1"
mkdir y
cd y
rm -rf ../y
"$pip" --version
$ bash t.sh 21.3.1
+ pip=/tmp/y/venv/bin/pip
+ /tmp/y/venv/bin/pip install pip==21.3.1
Collecting pip==21.3.1
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 27.9 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.4
    Uninstalling pip-22.0.4:
      Successfully uninstalled pip-22.0.4
Successfully installed pip-21.3.1
+ mkdir y
+ cd y
+ rm -rf ../y
+ /tmp/y/venv/bin/pip --version
pip 21.3.1 from /tmp/y/venv/lib/python3.8/site-packages/pip (python 3.8)
$ bash t.sh 22.0.4
+ pip=/tmp/y/venv/bin/pip
+ /tmp/y/venv/bin/pip install pip==22.0.4
Requirement already satisfied: pip==22.0.4 in ./venv/lib/python3.8/site-packages (22.0.4)
+ mkdir y
+ cd y
+ rm -rf ../y
+ /tmp/y/venv/bin/pip --version
Traceback (most recent call last):
  File "/tmp/y/venv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/configuration.py", line 20, in <module>
    from pip._internal.exceptions import (
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_internal/exceptions.py", line 14, in <module>
    from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
  File "/tmp/y/venv/lib/python3.8/site-packages/pip/_vendor/rich/__init__.py", line 16, in <module>
    _IMPORT_CWD = os.path.abspath(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory

@pradyunsg
Copy link
Member

mkdir y
cd y
rm -rf ../y

Ah, of course. :)

@pradyunsg
Copy link
Member

I've gone ahead and reported this upstream. We'll pull in the fix for this, in the pip release after this gets fixed + released in Rich.

I'm going to eagerly close this, even though we usually track upstream fixes for issues -- this doesn't seem like something that foundationally affects pip's core functionality except in a weird edge case.

@willmcgugan
Copy link

Will be fixed in the next release of Rich.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
project: vendored dependency Related to a vendored dependency type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants