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.

How to set the full name of the virtualenv created

See original GitHub issue

When using inside my project directory PROJECTDIR

pipenv install

pipenv creates a virtualenv named "PROJECTDIR-<someid>". How can I specify this full name myself, say to call the virtualenv just "PROJECTDIR"?

And how can I tell pipenv to use an existing virtualenv for this directory and just add the new packages from the requirements.txt?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:24
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
uranusjrcommented, Dec 21, 2017

This has been discussed multiple times in the past. You can search the issue tracker for similar entries. To sum things, it is not possible (at this time; can’t say for the future) to specify the name of the virtualenv, since Pipenv relies on this information to associate it to your project. The alternative is to set environment variable PIPENV_VENV_IN_PROJECT to tell Pipenv to look for the a directory named .venv inside your project (the same level as Pipfile).

To import dependencies from requirements.txt, use pipenv install -r. This converts the requirements file to a Pipfile, and use it to create the environment. There is not way to specify an existing virtualenv (unless you name it exactly the same as Pipenv would).

Most of the above is mentioned in detail in the documentation. Please check out relevant sections for more information.

https://docs.pipenv.org

8reactions
ianyoungcommented, Aug 29, 2021

One of my main issues with not being able to choose a name for the virtual environment is that it doesn’t take into account varying folder structures. I usually follow a common convention and like to nest my source code inside a /src directory of my main project folder. In the /Users/NAME/.local/share/virtualenvs directory every virtual env looks like:

src-Q4dXJo6L
src-ha_K95Ys
...

This makes it a little harder to distinguish between them.

This is also problematic when you have a frontend and backend in your repo, each with separate Pipenv files for separate dependencies. Again, I’d ideally like to name the project PROJECT-frontend and PROJECT-backend. With the hash suffix on both of those.

It would be nice to have a little control on the virtual environment naming.

Read more comments on GitHub >

github_iconTop Results From Across the Web

venv — Creation of virtual environments — Python 3.11.1 ...
Running this command creates the target directory (creating any parent directories that don't exist already) and places a pyvenv.cfg file in it with...
Read more >
Name Your Virtual Environments - Set Up a Python Environment
You can, of course, name your virtual environments however you wish. ... Create a file called .gitignore with the following contents:
Read more >
Python Virtual Environments: A Primer
In this tutorial, you'll learn how to work with Python's venv module to create and manage separate virtual environments for your Python ...
Read more >
Pipenv & Virtual Environments
The name of the current virtual environment will now appear on the left of the prompt (e.g. (venv)Your-Computer:project_folder UserName$ ) to let you...
Read more >
Command Reference - Virtualenvwrapper - Read the Docs
Create a new virtualenv in the WORKON_HOME directory. ... A unique virtualenv name is generated. If -c or --cd is specified the working...
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