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.

Pipenv ignores active environment and creates new virtualenv anyway

See original GitHub issue

As recently as Pipenv v3.3.6, I manually created my own virtual environment, installed Pipenv into it, and used Pipenv to manage project packages within that already-active virtual environment.

But since then there seems to have been a change that disrupts that workflow, and now Pipenv appears to ignore the active virtual environment and insists on creating its own virtual environment with an appended hash.

Steps to reproduce

> fish --version
fish, version 2.5.0

> echo $WORKON_HOME
/Users/me/virtualenvs

> vf new -p python3 foo  # manual creation of `foo` virtual environment

> (foo) echo $VIRTUAL_ENV
/Users/me/virtualenvs/foo

> (foo) pip install pipenv

> (foo) pipenv --version
pipenv, version 3.5.4

> (foo) pipenv install django==1.11rc1
Creating a Pipfile for this project...
Creating a virtualenv for this project...

Expected result

Pipenv would use the currently-active virtual environment.

Observed result

Pipenv ignores the currently-active virtual environment and creates a new environment, as seen above.

Additional notes

I sincerely hope this is merely a bug, and that the answer to this is not, “Virtualenv is behaving as intended.” I say this because (1) Pipenv supported this use case last month, and (2) I believe that Pipenv should support this use case: namely, installing Pipenv into a virtual environment, installing packages into that already-active virtual environment, and not insisting on creating its own virtual environment. I suspect this was introduced in a81197d, but that’s just a guess.

In addition to other problems, this change breaks automatic linking of projects and virtual environments based on identical naming conventions. Up until now, I have always been able to workon foo, which automatically activates the foo environment and switches to the ~/projects/foo directory. This change breaks that automation.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
ajmazuriecommented, May 25, 2017

Chiming in as well; I’m already using pyenv and direnv to automatically create virtual environments for Python interpreters, and pipenv would be a welcome addition if it could make use of these existing environments rather than creating new ones. Saying this, I realize what I really need is an updated version of pip that manages Pipfiles.

4reactions
justinmayercommented, Mar 24, 2017

Hey @nateprewitt / @kennethreitz. Many thanks for your quick responses and insightful info.

I looked into the --system option, and assuming I understand correctly that it allows Pip to install into global system-wide site-packages, then I’m not sure that option adequately addresses the use case I described above. I never want Pipenv to install anything outside of a virtual environment, and it seems to me that this option might lead to that result if there is no currently-active virtual environment. Feel free to correct me if my understanding is wrong.

As @nateprewitt suggested, I think that adding an official feature that checks the $VIRTUAL_ENV variable and uses that as the “working” directory for pipenv commands sounds great. I understand the potential issue of folks not realizing they have a virtual environment active, but one of the many benefits of Pipenv is the ease with which the environment can be restored. 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip - Is there a way to make PipEnv install in whatever Python ...
I'd like to install a PipEnv based project, but not in a virtualenv. When I pipenv sync from within a Docker container I...
Read more >
Pipenv - Giacomo Debidda
Virtualenv location: /home/jack/.virtualenvs/my-dummy-repo-zmrIuv74. The command you have just entered creates a new virtual environment and ...
Read more >
Pipenv: promises a lot, delivers very little - Hacker News
It gives you the NodeJS + NPM way's "npm i", by creating a virtualenv and pip installing into it. It helps with specifying...
Read more >
30371 (Use pipenv to create venv for development) - Sage Trac
It generates a virtual env in src/.venv that contains all necessary Python packages, and an editable install of sage. Moreover, the installation of...
Read more >
Pipenv & Virtual Environments
Creating a virtualenv for this project... Using base prefix '/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6' New python executable ...
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