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.

--skip-lock: tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'

See original GitHub issue

Issue description

When using pipenv install --skip-lock, I get the error

tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'

because there is no [[source]] defined in the Pipfile.

The culprit is the following line of code from pipenv.project.Project.get_lockfile_meta:

sources = [dict(source) for source in self.parsed_pipfile["source"]]

which requires source key to be present in parsed Pipfile.

Workaround, add default [[source]] section for PyPI to your Pipfile:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

Expected result

A [[source]] section should not be required and installation proceed as normal.

Actual result

Installing dependencies from Pipfile…
Traceback (most recent call last):
  File "/opt/miniconda3/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 1874, in do_install
    keep_outdated=keep_outdated
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 1253, in do_init
    pypi_mirror=pypi_mirror,
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/core.py", line 795, in do_install_dependencies
    lockfile = project.get_or_create_lockfile(from_pipfile=True)
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/project.py", line 754, in get_or_create_lockfile
    lockfile_dict.update({"_meta": self.get_lockfile_meta()})
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/project.py", line 790, in get_lockfile_meta
    sources = [dict(source) for source in self.parsed_pipfile["source"]]
  File "/opt/miniconda3/lib/python3.7/site-packages/pipenv/vendor/tomlkit/container.py", line 500, in __getitem__
    raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'

Steps to replicate

Example Pipfile:

[packages]
pytest = "*"
tox = "*"

Run pipenv install --skip-lock.


Pipenv version: '2018.11.26'

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
uranusjrcommented, Nov 17, 2020

It seems like the fix was lost somehow (probably due to a merge). Reopening.

https://github.com/pypa/pipenv/blob/v2020.11.15/pipenv/project.py#L820-L833

2reactions
ddudnikcommented, Jun 4, 2020

Hey, looks like this issue is back in 2020.6.2 Caught the same error when running pipenv install --skip-lock and when requirements.txt file was present so that it’s used instead of a Pipfile

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release and Version History — pipenv 2022.12.20.dev0 ...
Fix a bug where passing –skip-lock when PIPFILE has no [SOURCE] section throws the error: “tomlkit.exceptions.NonExistentKey: 'Key “source” does not exist.
Read more >
pipenv Documentation - Read the Docs
Fix a bug where passing –skip-lock when PIPFILE has no [SOURCE] section throws the error: “tom- lkit.exceptions.NonExistentKey: 'Key “source” does not exist ......
Read more >
How to use the tomlkit.loads function in tomlkit - Snyk
To help you get started, we've selected a few tomlkit.loads examples, based on popular ... """Dependencies of pyproject.toml files should not have versions....
Read more >
Bountysource
skip-lock : tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.'
Read more >
72835f142c8010f686ca26af21f3f...
Fix a bug where passing --skip-lock when PIPFILE has no [SOURCE] section throws the error: "tomlkit.exceptions.NonExistentKey: 'Key "source" does not exist.
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