Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pipenv `ModuleNotFoundError: No module named 'pip.basecommand`

I'm trying to create a virtual environment using pipenv. When I give the command pipenv install, I get the following error

I am using pipenv==2018.6.25

Traceback (most recent call last): File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib_compat.py", line 33, in do_import _tmp = importlib.import_module(internal) File "c:\programdata\anaconda3\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'pip._internal.basecommand'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\ProgramData\Anaconda3\Scripts\pipenv.exe__main__.py", line 5, in File "c:\programdata\anaconda3\lib\site-packages\pipenv__init__.py", line 23, in from .cli import cli File "c:\programdata\anaconda3\lib\site-packages\pipenv\cli.py", line 26, in from .utils import is_valid_url File "c:\programdata\anaconda3\lib\site-packages\pipenv\utils.py", line 59, in from .vendor.requirementslib import Requirement File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib__init__.py", line 6, in from .models import Requirement, Lockfile, Pipfile File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib\models__init__.py", line 8, in from .requirements import Requirement File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib\models\requirements.py", line 15, in from .markers import PipenvMarkers File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib\models\markers.py", line 6, in from .utils import validate_markers, filter_none File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib\models\utils.py", line 9, in from .._compat import Link File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib_compat.py", line 55, in Command = do_import("basecommand", "Command") File "c:\programdata\anaconda3\lib\site-packages\pipenv\vendor\requirementslib_compat.py", line 35, in do_import _tmp = importlib.import_module(pip9) File "c:\programdata\anaconda3\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named 'pip.basecommand'

Anybody has any idea how I can correct this error?

like image 702
chidimo Avatar asked Nov 05 '18 11:11

chidimo


2 Answers

I just ran into a similar error during pipenv lock.

After updating pipenv via pip install --user --upgrade pipenv and pip via python -m pip install --upgrade pip the lock command resulted in an error message rather than the traceback. This error message stated:

There are incompatible versions in the resolved dependencies.

like image 52
yveso Avatar answered Oct 07 '22 09:10

yveso


You may want to upgrade pipenv to the latest version. I had the same issue, now I installed version 2018.11.26, pipenv lock works flawlessly.

  • Run pip install pipenv --upgrade, this will install the latest pipenv. If there's permission error use sudo as a prefix or add --user parameter.
  • Once it's installed re-source the PATH by running source towards your shell config file, in my case source ~/.bashrc
like image 4
aluk.e Avatar answered Oct 07 '22 09:10

aluk.e