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.

Regression 2018-11-14 when using --pre flag with particular Pipfile syntax | TypeError: list indices must be integers or slices, not tuple

See original GitHub issue

Issue description

I started getting the following error when attempting to use pipenv versions 2018-11-14 (still exists in 2018-11-26) when installing with the --pre flag: pipenv install --pre.

Expected result

Pipenv installs packages.

Actual result

Pipenv fails with TypeError (this is with the --verbose flag)

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 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/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 "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1862, in do_install
    project.update_settings({"allow_prereleases": pre})
  File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 583, in update_settings
    p["pipenv"] = settings
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/tomlkit/container.py", line 524, in __setitem__
    self.append(key, value)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/tomlkit/container.py", line 176, in append
    return self._insert_after(key_after, key, item)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/tomlkit/container.py", line 246, in _insert_after
    current_item = self._body[idx][1]
TypeError: list indices must be integers or slices, not tuple

Steps to replicate

  1. Ensure pipenv version 2018-11-26 is installed.
  2. Run pipenv install --pre
  3. Observe TypeError

Support diagnostics file available upon request.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
frostmingcommented, Nov 28, 2018

The root cause:

packages section is splitted in several places, in this case, appending a new table(pipenv section) will throw an error.

The workaround is to combine the packages section in one place, and I pushed a PR to the upstream https://github.com/sdispater/tomlkit/pull/34 to fix this.

0reactions
frostmingcommented, Dec 9, 2018

@techalchemy The fix has been in tomlkit’s master but not released yet. Since this issue is corner case and has a workaround available, i’ll update the vendor after the upstream is released.

BTW This toml is allowed by spec

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: list indices must be integers or slices not tuple
Conclusion # The Python "TypeError: list indices must be integers or slices, not tuple" occurs when we pass a tuple between the square...
Read more >
Python error TypeError: list indices must be integers or slices ...
after removing the end bracket which is making the compiler to think it as a tuple instead of integer. Apply same to id_ratings...
Read more >
Python TypeError: list indices must be integers, not tuple
The “TypeError: list indices must be integers, not tuple” error occurs when you specify a tuple as an index value at the end...
Read more >
TypeError list indices must be integers or slices not tuple
Have you had a list of lists and received the TypeError list indices must be integers or slices not tuple when trying to...
Read more >
Python error: list indices must be integers or slices, not a tuple
The python programming language is very easy to learn. It has easy-to-understand and straightforward syntax that makes it easy to understand for everyone....
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