ImportError in system pip wrappers after an upgrade
envgap__pypa__pip-5599
Original GitHub issue ↗Opened 2018-07-13
01 / FAILURE SIGNATURE
As reported upstream
* `ImportError: cannot import name 'main'`
Not a benchmark task.
- No curated issue-specific recipe or verified environment fix is available.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
requirements.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
pypa/pip #5599 · read the original issue
## Overview After upgrading to pip 10 or higher, many users are encountering error like * `ImportError: cannot import name 'main'` * [`TypeError: 'module' object is not callable`](https://github.com/pypa/pip/issues/5599#issuecomment-541960822) * [`ImportError: No module named _internal`](https://github.com/pypa/pip/issues/5253#issue-314720523) * [`ModuleNotFoundError: No module named 'pip._internal'`](https://github.com/pypa/pip/issues/5373#issue-320586093) These are caused by an incorrect attempt to upgrade pip, which has typically resulted in (parts of) multiple versions of pip being installed in the same Python installation, and those parts being incompatible. It should be noted that these issues are invariably *not* problems with pip itself, but are due to incorrect use of pip, or unexpected interactions with system scripts that are not controlled by pip. So while we'll try to help you solve your issue, this is *not* the "fault" of pip, and you will have to be prepared to do at least some of the debugging and fixes on your own. You can reach out to your Python provider (eg: Linux Distro, Cloud Provider, etc) for help with this issue. ## General Advice First, some general advice. It is assumed that anyone encountering issues will have failed to follow some part of this advice. Listing these items here is not intended to imply that "it's your fault and we won't help", but rather to help users to identify what went wrong, so that they can work out what to do next more easily. 1. **Only ever use your system package manager to upgrade the system pip**. The system installed pip is owned by the distribution, and if you don't use distribution-supplied tools to manage it, you will hit problems. Yes, we know pip says "you should upgrade with pip install -U pip" - that's true in a pip-managed installation, ideally distributions should patch this message to give appropriate instructions in the system pip, but they don't. We're working with them on this, but it's not going to happen soon (remember, we're looking at cases where people are upgrading old versions of pip here, so patches to new versions won't help). 2. **Never use sudo with pip**. This follows on from the first point. If you think you need to use sudo, you're probably trying to modify a distribution-owned file. See point 1. 3. **Prefer to use `--user`**. By doing this, you only ever install packages in your personal directories, and so you avoid interfering with the system copy of pip. But there are `PATH` issues you need to be aware of here. We'll cover these later. Put simply, it's possible to follow this advice, and still hit problems, because you're not actually running the wrapper you installed as `--user`. ## Debugging the Issue Before trying to work out what's going on, it's critically important that you understand precisely what scripts you are running and what versions of pip the relevant Python interpreter is using. First, identify the full absolute p
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
Issue-specific recipe and runtime smoke command require review against the complete issue and repository.
Legacy already_works is install-only; proposed control still requires runtime verification.