question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError when during `pipenv install <package>`

See original GitHub issue

Key error when installing dependency. It seams to happen when pipenv is trying to add dependency to Pipfile:

Action:

pipenv install mock

Environment

  1. MacOS 10.12.6 Sierra
  2. Python version: 3.6.4
  3. Pipenv version: 8.3.2
Expected result

No KeyError raised. Dependency added to Pipfile.

Actual result

KeyError raised. Dependency is not added to Pipfile.

Installing mock…
Requirement already satisfied: mock in /Users/robin/.local/share/virtualenvs/ATG-PATKL30Y/lib/python3.6/site-packages
Requirement already satisfied: pbr>=0.11 in /Users/robin/.local/share/virtualenvs/ATG-PATKL30Y/lib/python3.6/site-packages (from mock)
Requirement already satisfied: six>=1.9 in /Users/robin/.local/share/virtualenvs/ATG-PATKL30Y/lib/python3.6/site-packages (from mock)

Adding mock to Pipfile's [packages]…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1923, in install
    project.add_package_to_pipfile(package_name, dev)
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 461, in add_package_to_pipfile
    p = self._pipfile
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 268, in _pipfile
    p_section[norm_key] = p_section.pop(key)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/prettytoml/elements/table.py", line 114, in pop
    v = self[key]
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/prettytoml/elements/abstracttable.py", line 58, in __getitem__
    raise KeyError
KeyError

Steps to replicate

Use this Pipfile

[[source]]

verify_ssl = true
url = "https://pypi.python.org/simple"


[requires]

python_version = '3.6'


[packages]

xlrd = "==1.1.0"
xlsxwriter = "==0.9.9"
pip-conflict-checker = "==0.3"
mypy = "==0.530"
pylint = "==1.7.4"
hyperopt = "==0.1"
networkx = "==1.11"
pyyaml = "==3.12"
scipy = "==0.18.1"
scikit-learn = "==0.19.1"


[dev-packages]

tensorflow = "==1.4.0"
matplotlib = "==2.1.1"

Then install mock with: pipenv install mock

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
frostmingcommented, Sep 12, 2019

@monkut It should be gone in master branch.

1reaction
philgyfordcommented, Feb 10, 2020

I think it’s this line in my Pipfile that’s causing the problem:

wagtailcomments-xtd = {editable = true,git = "https://github.com/UnfoldStories/wagtailcomments_xtd.git",ref = "wagtail-2-fixes"}

I’ve tried installing that package afresh, doing this:

  1. pipenv --rm
  2. rm Pipfile.lock
  3. Comment out the wagtailcomments-xtd... line from Pipfile
  4. pipenv install --dev
  5. pipenv install -e git+https://github.com/UnfoldStories/wagtailcomments_xtd.git@wagtail-2-fixes#egg=wagtailcomments_xtd

The last step results in:

Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/cli/command.py", line 235, in install
    retcode = do_install(
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/core.py", line 1983, in do_install
    do_init(
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/core.py", line 1216, in do_init
    do_lock(
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/core.py", line 1058, in do_lock
    venv_resolve_deps(
  File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/utils.py", line 682, in venv_resolve_deps
    lockfile[lockfile_section][k].update(v)
KeyError: 'asgiref'

Neither this project nor that wagtailcomments_xtd repo have changed recently and this – doing pipenv updates – has been working OK for a few months.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`pipenv install` fails with " KeyError: 'url' " - Stack Overflow
I want to create a virtual environment using pipenv. Problem. In order to create a virtual environment, I used pipenv. However, even though...
Read more >
Working with the AWS CDK in Python
Managing AWS Construct Library modules. Use the Python package installer, pip, to install and update AWS Construct Library modules for use by your...
Read more >
pipenv Documentation - Read the Docs
This tutorial walks you through installing and using Python packages. It will show you how to install and use the necessary tools and...
Read more >
Common Pipenv Errors and How to Solve Them: Why Won't it ...
Be aware that the 'Installation Succeeded' alert is untrue; there is no Panadas to install. All that s occurred is the addition of...
Read more >
Unable to complete "cdktf init --template=python - r/Terraform
pipenv install cdktf~=0.4.1 ··· ✓ Warning: Your Pipfile requires ... line 530, in write_toml for package in data[section]: KeyError: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found