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.

Cannot install venv; toml.decoder.TomlDecodeError Found invalid character

See original GitHub issue

Issue description

When creating a virtual environment, I’m able to initially create the venv however there is an error which occurs after it is created. I’m using pyenv to manage my python versions.

✔ Successfully created virtual environment!


toml.decoder.TomlDecodeError: Found invalid character in key name: '\'. Try quoting the key name. (line 1 column 2 char 1)

Expected result

When I run $ pipenv install --three I expect the venv to be created, and then be able to add packages to it.

The things I think it might be are:

  1. When looking at my python versions I see /Users/me/.pyenv/versions/3.7.1/bin/python3.7m and I’m not sure what the m is
  2. When creating the venv it’s looking for a Pipfile that does not exist in the project folder, but rather one directory up. And I’m not sure why it is looking there.

Any help would be appreciated.


Actual result

project git:(master) ✗ pipenv install --three
Creating a virtualenv for this project…
Pipfile: /Users/me/Documents/Pipfile
Using /usr/local/bin/python3.7m (3.7.2) to create virtualenv…
⠦ Creating virtual environment...Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/me/.local/share/virtualenvs/Documents-3uxKDUNM-“/Users/me/.pyenv/shims/python”/bin/python3.7m
Also creating executable in /Users/me/.local/share/virtualenvs/Documents-3uxKDUNM-“/Users/me/.pyenv/shims/python”/bin/python
Installing setuptools, pip, wheel...
Running virtualenv with interpreter /usr/local/bin/python3.7m

✔ Successfully created virtual environment!
Traceback (most recent call last):
  File "/Users/me/src/pipenv/pipenv/", line 522, in _parse_pipfile
    return tomlkit.parse(contents)
  File "/Users/me/src/pipenv/pipenv/vendor/tomlkit/", line 49, in parse
    return Parser(string).parse()
  File "/Users/me/src/pipenv/pipenv/vendor/tomlkit/", line 132, in parse
    item = self._parse_item()
  File "/Users/me/src/pipenv/pipenv/vendor/tomlkit/", line 270, in _parse_item
    return self._parse_key_value(True)
  File "/Users/me/src/pipenv/pipenv/vendor/tomlkit/", line 339, in _parse_key_value
    raise self.parse_error(EmptyKeyError)
tomlkit.exceptions.EmptyKeyError: Empty key at line 1 col 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/me/.pyenv/versions/3.7.1/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv', 'console_scripts', 'pipenv')()
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/me/src/pipenv/pipenv/vendor/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/me/src/pipenv/pipenv/cli/", line 251, in install
  File "/Users/me/src/pipenv/pipenv/", line 1803, in do_install
  File "/Users/me/src/pipenv/pipenv/", line 554, in ensure_project
  File "/Users/me/src/pipenv/pipenv/", line 486, in ensure_virtualenv
    python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
  File "/Users/me/src/pipenv/pipenv/", line 939, in do_create_virtualenv
    sources = project.pipfile_sources
  File "/Users/me/src/pipenv/pipenv/", line 842, in pipfile_sources
    if "source" not in self.parsed_pipfile:
  File "/Users/me/src/pipenv/pipenv/", line 504, in parsed_pipfile
    parsed = self._parse_pipfile(contents)
  File "/Users/me/src/pipenv/pipenv/", line 526, in _parse_pipfile
    return toml.loads(contents)
  File "/Users/me/src/pipenv/pipenv/vendor/toml/", line 227, in loads
    original, i)
toml.decoder.TomlDecodeError: Found invalid character in key name: '\'. Try quoting the key name. (line 1 column 2 char 1)

Steps to replicate

I’m not sure how to recreate this beyond the steps above.

$ pipenv --support

Pipenv version: '2018.11.27.dev0'

Pipenv location: '/Users/me/src/pipenv/pipenv'

Python location: '/Users/me/.pyenv/versions/3.7.1/bin/python3.7'

Python installations found:

  • 3.7.2: /usr/local/bin/python3
  • 3.7.2: /usr/local/bin/python3.7m
  • 3.7.1: /Users/me/.pyenv/versions/3.7.1/bin/python3
  • 3.7.1: /Users/me/.pyenv/versions/3.7.1/bin/python3.7m

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.1',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '18.2.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST '
                     '2018; root:xnu-4903.241.1~1/RELEASE_X86_64',
 'python_full_version': '3.7.1',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • TERM
  • Apple_PubSub_Socket_Render
  • ZSH
  • USER
  • PATH
  • PWD
  • LANG
  • HOME
  • LESS

Pipenv–specific environment variables:

  • PIPENV_PYTHON: “/Users/me/.pyenv/shims/python”

Debug–specific environment variables:

  • PATH: /Users/me/.pyenv/versions/3.7.1/bin:/Users/me/.pyenv/libexec:/Users/me/.pyenv/plugins/python-build/bin:/usr/local/opt/openssl/bin:/usr/local/bin:/Users/me/.pyenv/shims:/Users/me/.pyenv/shims:/Users/me/.pyenv/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • SHELL: /bin/zsh
  • LANG: en_CA.UTF-8
  • PWD: /Users/me/project/

Contents of Pipfile (‘/Users/me/Documents/Pipfile’):

{\fonttbl\f0\fswiss\fcharset0 Helvetica;}

\f0\fs24 \cf0 [[source]]\
name = "pypi"\
url = ""\
verify_ssl = true\
pandas = "*"\
numpy = "*"\
matplotlib = "*"\
sklearn = "*"\
psycopg2 = "*"\
jupyter = "*"\
pystan = "*"\
fbprophet = "*"\
scipy = "*"\
ipykernel = "*"\
autopep8 = "*"\
jupyter-contrib-nbextensions = "*"\
jupyter-nbextensions-configurator = "*"\
python_version = "3.7"}

Issue Analytics

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

github_iconTop GitHub Comments

michael-burtcommented, Aug 21, 2019

I am having the same issue. It started after I removed my pycache in my package folder. I uninstalled pipenv and I am still hitting the same error. I removed pipenv and all associated venv’s and I still cannot get it to work. Any help would be appreciated.

To close this, I had a malformed Pipfile.

adaminfinitumcommented, Mar 14, 2020

I’m new to pipenv and so it’s trying to convert my requirements.txt file but that file includes specific subset libraries in brackets (e.g. django-webserver[pyuwsgi]). How do I make this work?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve toml.decoder.TomlDecodeError: Key group not ...
Just delete the config.toml file which can be found in the directory where you have installed streamlit.
Read more >
Python Examples of toml.TomlDecodeError -
This page shows Python examples of toml.TomlDecodeError.
Read more >
alg_final_stuff - .. - toml - - Whitgit
raise TomlDecodeError("Found invalid character in key name: '" +. 261. item + "'. Try quoting the key name.",. 262. original, i).
Read more >
Toml docoder error - Deploying Streamlit
As of this evening, I cannot do anything with streamlit, not even run the ... TomlDecodeError: Found invalid character in key name: '#'....
Read more >
pipenv Documentation - Read the Docs
Makefile, direct calls to pip and python -m venv or virtualenv. to create virtual environments and install pack- ages in them. Pipenv uses...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found