Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'platlibdir' during pipenv clean #3113

Closed
software-opal opened this issue Oct 27, 2018 · 4 comments
Closed

KeyError: 'platlibdir' during pipenv clean #3113

software-opal opened this issue Oct 27, 2018 · 4 comments
Assignees
Labels
Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior.

Comments

@software-opal
Copy link

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'
@techalchemy
Copy link
Member

Thanks for the thorough debug info. Would you mind trying out pip install -e git+https://github.com/pypa/pipenv.git@update-vendor#egg=pipenv and let me know if this still happens

@software-opal
Copy link
Author

I'm going to open a new issue into the --support weirdness.

@software-opal
Copy link
Author

$ pipenv --verbose clean
Ignoring 'packaging'.
Ignoring 'pip'.
Ignoring 'setuptools'.
Ignoring 'wheel'.
Uninstalling 'yapf'…
Uninstalling 'snowballstemmer'…
Uninstalling 'rope'…
Uninstalling 'pytoml'…
Uninstalling 'python-language-server'…
Uninstalling 'python-jsonrpc-server'…
Uninstalling 'pydocstyle'…
Uninstalling 'pluggy'…
Uninstalling 'parso'…
Uninstalling 'jedi'…
Uninstalling 'future'…
Uninstalling 'flit'…
Uninstalling 'docutils'…
Uninstalling 'autopep8'…

Woo, it works(also happy Halloween). I'm still getting the --support errors; but they're tracked in #3121.

@techalchemy techalchemy added Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior. labels Oct 29, 2018
@techalchemy techalchemy self-assigned this Oct 29, 2018
@techalchemy
Copy link
Member

ok this was fixed in #3096, going to add a news entry for it and close it out

techalchemy added a commit that referenced this issue Oct 30, 2018
- Fix inadvertent occasional global installation of files
- Fix inadvertent occcasional global removal of files
- Fix empty output from `pipenv update --outdated`
- Fixes #2828
- Fixes #3113
- Fixes #3047
- Fixes #3055

Signed-off-by: Dan Ryan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior.
Projects
None yet
Development

No branches or pull requests

2 participants