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.

pipenv sync raises `ValueError: Path not found or generated` when `PIPENV_VENV_IN_PROJECT=1` and `.venv/bin` doesn't exist

See original GitHub issue

pipenv 2022.01.08 doesn’t properly support creating a new virtual environment in the project (using PIPENV_VENV_IN_PROJECT=1) if there’s isn’t already an existing one. This makes it hard to do a clean install.

More specifically, if PIPENV_VENV_IN_PROJECT=1 and the .venv/bin directory doesn’t exist within the project directory, pipenv sync raises ValueError: Path not found or generated rather than simply creating the directory (as was done in previous versions). See the repro steps below:

The initial state is a project directory with an initialized pipenv virtual environment

$ pipenv --version
pipenv, version 2022.1.8
$ pwd
$ pipenv --venv
$ pipenv --rm
$ pipenv sync --dev
Traceback (most recent call last):
  File "/home/vscode/.pyenv/versions/3.7.4/bin/pipenv", line 10, in <module>
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/click/", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/cli/", line 657, in sync
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 2842, in do_sync
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 531, in ensure_project
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 452, in ensure_virtualenv
    python = ensure_python(project, three=three, python=python)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 344, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 313, in find_a_system_python
    python_entry = find_python(finder, line)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/", line 2230, in find_python
    result = finder.find_python_version(line)
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/", line 288, in find_python_version
    return self.system_path.find_python_version(
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/", line 120, in system_path
    self._system_path = self.create_system_path()
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/", line 86, in create_system_path
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/", line 683, in create
    instance = instance._run_setup()
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/", line 251, in _run_setup
    paths[p] = new_instance.get_path(p.joinpath(bin_dir))
  File "/home/vscode/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/", line 439, in get_path
    raise ValueError("Path not found or generated: {0!r}".format(path))
ValueError: Path not found or generated: PosixPath('/workspaces/project/.venv/bin')
$ mkdir -p .venv/bin
$ pipenv sync --dev
Creating a virtualenv for this project...
# Output not shown, but pipenv successfully created the environment

As shown above:

  • pipenv is configured to install the virtual environment within the project directory in the .venv dir. This is configured using PIPENV_VENV_IN_PROJECT=1
  • We started with an existing pipenv virtual environment (i.e., the Pipfile.lock exists and the virtual environment is installed in .venv within the project directory)
  • We run pipenv --rm to remove the existing environment (this removes the .venv dir)
  • Running pipenv sync --dev now fails with ValueError: Path not found or generated
  • After simply creating an empty directory .venv/bin, now pipenv sync --dev works fine

I do no know when this bug was introduced, but I know that it did not exist in 2018.11.26 but does exist in 2022.01.08.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

JCapriotticommented, Feb 15, 2022

I just had a very similar issue, with the same version of Pipenv. , in my case it was complaining about a path that seemed to relate to a Pipenv environment I had just removed:

ValueError: Path not found or generated: PosixPath('/Users/jasonc/.local/share/virtualenvs/my-project-Nt-iynbk/bin')

May or may not be related, but I also just recently installed pyenv. I’m not familiar with how pyenv works internally, so I decided I’d try reinstalling Pipenv. I had originally installed it with pip install pipenv, this time I installed it with Homebrew.

That didn’t work, but then I noticed that directory I mentioned above was in my PATH variable, so I closed/restarted my shell and the issue disappeared.

I have no idea how the PATH got messed up, that was my problem.

asmaiercommented, Jun 15, 2022

I believe this happens when you call pipenv --rm while you are still inside pipenv shell. This will mess up your PATH variable. So don’t do this:

pipenv shell
pipenv --rm
pipenv install

Instead you must do this

pipenv shell
pipenv --rm
pipenv install
Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError when trying to use pipenv install - Stack Overflow
I have python installed in 'D:/python382' There is no such directory that the error mentions. I have checked my environment variables and ...
Read more >
Frequently Encountered Pipenv Problems - Read the Docs
☤ My pyenv-installed Python is not found​​ Make sure you have PYENV_ROOT set correctly. Pipenv only supports CPython distributions, with version name like...
Read more >
pipenv Documentation - Read the Docs
Automatically generates a Pipfile, if one doesn't exist. • Automatically creates a virtualenv in a standard customizable location. • Automatically adds/removes ...
Read more >
Configure a Pipenv environment | PyCharm Documentation
Install pipenv by running the following command: $ pip install --user pipenv · For your convenience, you might add the user base's binary...
Read more >
Release and Version History — pipenv 2022.12.20.dev0 ...
Bug Fixes¶ · virtualenv creation no longer uses --creator=venv by default; introduced two environment variables: PIPENV_VIRTUALENV_CREATOR – May be specified to ...
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