ModuleNotFoundError: No module named 'pip._internal.cli.main'
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: CentOS7
-
Poetry version: 1.1.3
-
Python version: Python 3.6.8
-
Pip version: pip 20.2.2 from /home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/lib/python3.6/site-packages/pip (python 3.6)
Issue
After creating a fresh, local install of poetry and making sure that ~/.cache/pypoetry is gone, I created a new project. I then modified the pyproject.toml file to add a local PyPI mirror:
[[tool.poetry.source]]
name = "company"
url = "https://pypi.company.com/simple"
default = true
And then in that new project, I tried to add a module that I’d previously created and published with an earlier version of poetry, which was hosted on our local pypi repo.
This fails with the following output.
▶ poetry add seg-tools -vvv
Using virtualenv: /home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6
company: 2 packages found for seg-tools *
Using version ^0.1.1 for seg-tools
Updating dependencies
Resolving dependencies...
1: fact: bkt is 0.1.0
1: derived: bkt
1: fact: bkt depends on seg-tools (^0.1.1)
1: fact: bkt depends on pytest (^5.2)
1: fact: bkt depends on pytest (^5.2)
1: selecting bkt (0.1.0)
1: derived: pytest (^5.2)
1: derived: seg-tools (^0.1.1)
1: fact: pytest (5.4.3) depends on py (>=1.5.0)
1: fact: pytest (5.4.3) depends on packaging (*)
1: fact: pytest (5.4.3) depends on attrs (>=17.4.0)
1: fact: pytest (5.4.3) depends on more-itertools (>=4.0.0)
1: fact: pytest (5.4.3) depends on pluggy (>=0.12,<1.0)
1: fact: pytest (5.4.3) depends on wcwidth (*)
1: fact: pytest (5.4.3) depends on importlib-metadata (>=0.12)
1: fact: pytest (5.4.3) depends on atomicwrites (>=1.0)
1: fact: pytest (5.4.3) depends on colorama (*)
1: selecting pytest (5.4.3)
1: derived: colorama (*)
1: derived: atomicwrites (>=1.0)
1: derived: importlib-metadata (>=0.12)
1: derived: wcwidth (*)
1: derived: pluggy (>=0.12,<1.0)
1: derived: more-itertools (>=4.0.0)
1: derived: attrs (>=17.4.0)
1: derived: packaging (*)
1: derived: py (>=1.5.0)
company: 1 packages found for seg-tools >=0.1.1,<0.2.0
1: selecting seg-tools (0.1.1)
1: selecting colorama (0.4.4)
1: selecting atomicwrites (1.4.0)
1: fact: importlib-metadata (2.0.0) depends on zipp (>=0.5)
1: selecting importlib-metadata (2.0.0)
1: derived: zipp (>=0.5)
1: selecting wcwidth (0.2.5)
1: fact: pluggy (0.13.1) depends on importlib-metadata (>=0.12)
1: selecting pluggy (0.13.1)
1: selecting more-itertools (8.5.0)
1: selecting attrs (20.2.0)
1: fact: packaging (20.4) depends on pyparsing (>=2.0.2)
1: fact: packaging (20.4) depends on six (*)
1: selecting packaging (20.4)
1: derived: six (*)
1: derived: pyparsing (>=2.0.2)
1: selecting py (1.9.0)
1: selecting zipp (3.3.1)
1: selecting six (1.15.0)
1: selecting pyparsing (2.4.7)
1: Version solving took 0.119 seconds.
1: Tried 1 solutions.
Finding the necessary packages for the current system
Package operations: 1 install, 10 updates, 2 removals, 1 skipped
• Removing atomicwrites (1.4.0): Pending...
• Removing atomicwrites (1.4.0): Removing...
• Removing atomicwrites (1.4.0): Failed
EnvCommandError
Command ['/home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/bin/pip', 'uninstall', 'atomicwrites', '-y'] errored with the following return code 1, and output:
Traceback (most recent call last):
File "/home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
at ~/.poetry/lib/poetry/utils/env.py:948 in _run
944│ output = subprocess.check_output(
945│ cmd, stderr=subprocess.STDOUT, **kwargs
946│ )
947│ except CalledProcessError as e:
→ 948│ raise EnvCommandError(e, input=input_)
949│
950│ return decode(output)
951│
952│ def execute(self, bin, *args, **kwargs):
• Removing colorama (0.4.4): Pending...
• Removing colorama (0.4.4): Removing...
• Removing colorama (0.4.4): Failed
EnvCommandError
Command ['/home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/bin/pip', 'uninstall', 'colorama', '-y'] errored with the following return code 1, and output:
Traceback (most recent call last):
File "/home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
at ~/.poetry/lib/poetry/utils/env.py:948 in _run
944│ output = subprocess.check_output(
945│ cmd, stderr=subprocess.STDOUT, **kwargs
946│ )
947│ except CalledProcessError as e:
→ 948│ raise EnvCommandError(e, input=input_)
949│
950│ return decode(output)
951│
952│ def execute(self, bin, *args, **kwargs):
Failed to add packages, reverting the pyproject.toml file to its original content.
Were I to then run this command from the shell, it completes fine with the following warning:
▶ /home/bphunter/.cache/pypoetry/virtualenvs/bkt-Xs-I_Sti-py3.6/bin/pip uninstall atomicwrites -y
WARNING: Skipping atomicwrites as it is not installed.
▶ echo $!
0
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Mann what should I do pip is nowhere to be found… Please help
I’m having this problem on MacOS 11.14.6, poetry 1.1.5. Running poetry install builds the venv fine, but then if I try to remove an installed repo I get the error No module named pip. I’ve deleted and re-built the venv 4 times already today. not sure what the root issue is.
I did notice, however, that when I run
poetry remove my-repo
it deletes the entire contents ofmy-venv/lib/python3.8/site-packages
, consequently, deleting pip and all other python standard libraries. It starts by deleting the indicated repo (i.e. my-repo) and then the deletion cascades until the entire folder contents have been deleted.can’t imagine that this is intended behaviour, and so I request that this issue be re-opened.