Skip to content

KeyError: 'platlibdir' during pipenv clean #3113

Closed
@software-opal

Description

Issue description

When running pipenv clean I get an exception.

Expected result

A successful pipenv clean.

Actual result

From inside a completely empty directory(I get the same error from projects I'm working on too):

$ pipenv --verbose clean
Creating a virtualenv for this project…
Pipfile: /home/opal/piwik3/test2/Pipfile
Using /usr/bin/python3 (3.6.5) to create virtualenv…
⠦Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/opal/.local/share/virtualenvs/test2-6x3m17Ja/bin/python3
Also creating executable in /home/opal/.local/share/virtualenvs/test2-6x3m17Ja/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /home/opal/.local/share/virtualenvs/test2-6x3m17Ja
Creating a Pipfile for this project…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (ca72e7)!
Traceback (most recent call last):
  File "/home/opal/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 602, in clean
    do_clean(ctx=ctx, three=state.three, python=state.python, dry_run=dry_run)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/core.py", line 2526, in do_clean
    canonicalize_name(pkg.project_name) for pkg in project.get_installed_packages()
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/project.py", line 320, in get_installed_packages
    packages = [pkg for pkg in workingset if self.dist_is_in_project(pkg)]
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/project.py", line 320, in <listcomp>
    packages = [pkg for pkg in workingset if self.dist_is_in_project(pkg)]
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/project.py", line 311, in dist_is_in_project
    prefix = _normalized(self.env_paths["prefix"])
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/project.py", line 951, in env_paths
    for k, v in sysconfig._INSTALL_SCHEMES[scheme].items()
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/project.py", line 951, in <dictcomp>
    for k, v in sysconfig._INSTALL_SCHEMES[scheme].items()
KeyError: 'platlibdir'

Steps to replicate

I haven't had this command work. I am running OpenSUSE Tumbleweed. I used pyenv to install the latest python 3.6, however I'm not sure if that integration is working.

>>> import sysconfig
>>> from pprint import pprint
>>> pprint(sysconfig._INSTALL_SCHEMES)
{'nt': {'data': '{base}',
        'include': '{installed_base}/Include',
        'platinclude': '{installed_base}/Include',
        'platlib': '{base}/Lib/site-packages',
        'platstdlib': '{base}/Lib',
        'purelib': '{base}/Lib/site-packages',
        'scripts': '{base}/Scripts',
        'stdlib': '{installed_base}/Lib'},
 'nt_user': {'data': '{userbase}',
             'include': '{userbase}/Python{py_version_nodot}/Include',
             'platlib': '{userbase}/Python{py_version_nodot}/site-packages',
             'platstdlib': '{userbase}/Python{py_version_nodot}',
             'purelib': '{userbase}/Python{py_version_nodot}/site-packages',
             'scripts': '{userbase}/Python{py_version_nodot}/Scripts',
             'stdlib': '{userbase}/Python{py_version_nodot}'},
 'osx_framework_user': {'data': '{userbase}',
                        'include': '{userbase}/include',
                        'platlib': '{userbase}/lib/python/site-packages',
                        'platstdlib': '{userbase}/lib/python',
                        'purelib': '{userbase}/lib/python/site-packages',
                        'scripts': '{userbase}/bin',
                        'stdlib': '{userbase}/lib/python'},
 'posix_home': {'data': '{base}',
                'include': '{installed_base}/include/python',
                'platinclude': '{installed_base}/include/python',
                'platlib': '{base}/lib/python',
                'platstdlib': '{base}/lib/python',
                'purelib': '{base}/lib/python',
                'scripts': '{base}/bin',
                'stdlib': '{installed_base}/lib/python'},
 'posix_prefix': {'data': '{base}',
                  'include': '{installed_base}/include/python{py_version_short}{abiflags}',
                  'platinclude': '{installed_platbase}/include/python{py_version_short}{abiflags}',
                  'platlib': '{platbase}/{platlibdir}/python{py_version_short}/site-packages',
                  'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}',
                  'purelib': '{base}/lib/python{py_version_short}/site-packages',
                  'scripts': '{base}/bin',
                  'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}'},
 'posix_user': {'data': '{userbase}',
                'include': '{userbase}/include/python{py_version_short}',
                'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
                'platstdlib': '{userbase}/lib/python{py_version_short}',
                'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
                'scripts': '{userbase}/bin',
                'stdlib': '{userbase}/lib/python{py_version_short}'}}

Adding import pprint; pprint.pprint(config) at pipenv/project.py:956 provides the following dict:

{'abiflags': 'm',
 'base': '/home/opal/.local/share/virtualenvs/test2-6x3m17Ja',
 'installed_base': '/home/opal/.local/share/virtualenvs/test2-6x3m17Ja',
 'installed_platbase': '/home/opal/.local/share/virtualenvs/test2-6x3m17Ja',
 'platbase': '/home/opal/.local/share/virtualenvs/test2-6x3m17Ja',
 'py_version_short': '3.6'}

$ pipenv --support

Pipenv version: '2018.10.13'

Pipenv location: '/home/opal/.local/lib/python3.6/site-packages/pipenv'

Python location: '/usr/bin/python3'

Python installations found:

Traceback (most recent call last):
  File "/home/opal/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 142, in cli
    get_pipenv_diagnostics()
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 112, in find_all_python_versions
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch
  File "/home/opal/.local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 222, in find_all_python_versions
    return [c for c in sorted(path_filter, key=version_sort, reverse=True)]
AttributeError: 'list' object has no attribute 'as_python'

Metadata

Assignees

Labels

Type: Bug 🐛This issue is a bug.Type: RegressionThis issue is a regression of a previous behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions