pipenv: Default virtualenv location and pipenv shell problems
Hello, i have noticed that pipenv creates virtualenv in new directory, which is highly unacceptable for our company, because of our project deployment tools are targeting .venv in project directory. How do we configure that? Also, hiding virtualenv on .local/share/virtualenv looks like bad practice:
- you never know if virtualenv you need exists
- system gets polluted with different virtualenvs
- you now need to manually handle virtualenvs
- it is harder to work with if you need to recreate virtualenv manually — this is just not obvious.
Virtualenv location: /home/asyncee/.local/share/virtualenvs/project
And secondly, i get this error after running pipenv shell
:
Spawning environment shell (/bin/zsh).
ERROR: The virtualenv hasn't been activated correctly.
Either the env is corrupted (try running `pew restore env`),
Or an upgrade of your Python version broke your env,
Or check the contents of your $PATH. You might be adding new directories to it
from inside your shell's configuration file.
In this case, for further details please see: https://github.com/berdario/pew#the-environment-doesnt-seem-to-be-activated
Yesterday (before new location) everything was working fine — my python installation did not change.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 24
- Comments: 20 (9 by maintainers)
no plans for making it configurable.
it sounds like your shell is not properly configured.
released!
added
PIPENV_VENV_IN_PROJECT
mode for classic operation. Not released yet.Please add an option in the
Pipfile
to enablePIPENV_VENV_IN_PROJECT
behavior. Requiring an environment variable defeats the purpose of thePipfile
/pipenv
.I think at the moment I’m only proposing a change of:
…to show the virtualenv location at
/Users/kennethreitz/.local/share/virtualenvs
etc.It would have helped me if it said, instead of:
…perhaps
in a central location, but configurable.
. But again, it’s likely only me that is bugged by the change in policy. I spent quite a while looking for a discussion about the rationale, but couldn’t find it. Still, it’s a fast-moving project designed to have opinions, and nobody owes me squat. 😃From a system administration perspective, it makes more sense to default to store the venv in the project, because if we simply remove the project, there are no artifacts on the system. Also, it does not appear to be instinctive to know which venv are artifacts (to save space).
From a developer perspective, it makes more sense to default to store the venv in the project, because it means we can simply share the projects folder with someone else, no installation step required. Which was one of the purposes of the initial venv.
From https://virtualenv.pypa.io/en/latest/:
About the softwares that need a central location for the venv (I must warn that I don’t know all the reasons those softwares need a central location). From my point of view, those softwares could:
To conclude, I don’t see any advantages (except for third party utilities) to have a central location for venv (please correct me on this). I understand that it would involve some work for third party utilities, but I think this is the kind of change that should be made on a major update.
I just want to point out this makes installing packages from
Pipfile.lock
easier in docker/containers without shipping pipenv in the final build, allowing us to trivially copy only.venv
and relevant source code to the final image without having to determine the package venv directory by hash/location etc.Hrm, this doesn’t work as expected:
Pipfile found at /Users/myusername/Desktop/dev/projectname/Pipfile. Considering this to be the project home.
What I would expect is: /Users/myusername/.local/share/virtualenvs/projectname
Then I can programmatically use pipenv --where with other shell commands to do things like manually linking system opencv.
Yep, I gave that env var a try and it worked. However, it’s no longer the default behavior, so I thought I’d note that the home page is out of date in that regard.
I agree it is a minor detail, and it’s likely only me that notices it, because I’m disappointed at the change of default. But that’s an emacs vs. vi argument that doesn’t need to be re-opened.
—Paul
@madhavajay Maybe you’re looking for
pipenv --venv
instead?Hey @pauleveritt, just to be clear, the virtualenv in project dir functionality is still available but now requires an environment variable
PIPENV_VENV_IN_PROJECT
to activate. Placing this in your bash profile will enable this functionality as the default.I can only find one reference to a venv in the local directory and I don’t know if I’d consider that terribly misleading. We could change the path displayed but I’m not sure if that provides any significant improvement in understanding. Each project will tell you where it’s installed at initialization and is easy to find with
pipenv --where
.Thank you very much! I figured out that in new version you did use
pew
to manage virtualenv and that is great, butpew
is not supportingpyenv
, which i use, and this is what causes the problem. I decided to refuse ofpyenv
in favour ofpew
, but this issue may target all of pyenv users.this will also restore your shell functionality, although i would recommend fixing your shell configuration.