Circular imports in pip._vendor.requests
See original GitHub issueLooks like since pip 18.1 there’s a circular import problem. All versions including 18.1 and 19.1.1 produce something like this (traceback from 19.1.1 release):
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cli/base_command.py", line 25, in <module>
from pip._internal.index import PackageFinder
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 39, in <module>
from pip._internal.utils.packaging import check_requires_python
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/packaging.py", line 10, in <module>
from pip._internal import exceptions
ImportError: cannot import name exceptions
Contents of the bin script:
$ cat `which pip` #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Note that 18.0 doesn’t have the problem.
This happens on Ubuntu 18.04 if it matters (yes, pip is installed globally, python-pip deb package not installed of course).
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
Why do circular imports seemingly work further up in the ...
I think the answer by jpmc26, while by no means wrong, comes down too heavily on circular imports. They can work just fine,...
Read more >Python Circular Imports
Circular importing is a form of circular dependency that is created with the import statement in Python. For example, let's analyze the ...
Read more >Vendoring Policy - pip documentation v22.3.1
Vendored libraries MUST not be modified except as required to successfully vendor them. · Vendored libraries MUST be released copies of libraries available...
Read more >Python pip breaks and how to recover?
Reproduce $ pip install git+https://github.com/BingLingGroup/autosub.git@origin $ pip uninstall autosub (to remove dependecies of autosub, ...
Read more >Solving Circular Import Problem - Python
Circular importing is a conceptual error that is formed due to circular dependency created with the import statement in our Python program. Python...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
There’s still some crappy code if importing something from vendor first makes everything fall apart imo. Sure, from an user’s perspective it doesn’t matter (no one should be doing that) but from an maintainer’s perspective you gonna get bitten by that sooner or later.
I had put this previously in #6498 (comment), and after trying to implement it my argument against this test would be that we would have to either: