-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated. #6220
Comments
Pipenv forks the shell and activates the virtualenv in the forked shell, so you can just exit the shell (e.g. by running If you still want to re-use the forked shell, you can use the If we want to unset |
Thank you for your response. I will start using Thanks again for your help. |
Issue #6220 Analysis and Proposed Resolution1. Problem Summary: The issue highlights a problem with reactivating a Pipenv-created virtual environment after it has been deactivated using the
This error occurs because the 2. Comments Analysis:
3. Proposed Resolution: Given the nature of the problem and the comments, the best approach is to follow Naofal-Helal's suggestion of using the
4. Code Changes: a) Modify the error message in def is_in_virtualenv():
#... (existing code) ...
return virtual_env and not (pipenv_active or ignore_virtualenvs)
# In pipenv/cli/command.py
class PipenvGroup(DYMMixin, Group):
# ... (existing code) ...
def handle_error(self, exc_type, exc_value, traceback):
# ... (existing code) ...
elif isinstance(exc_value, exceptions.VirtualenvActivationException):
# Modify the error message here
click.secho(
'Pipenv environment for this project was previously activated in this shell.\n'
"Use the '--anyway' flag with 'pipenv shell' to reactivate.",
fg="yellow",
err=True,
) b) Update the documentation in Add a section that clearly describes the recommended workflow for activating and deactivating Pipenv environments: ## Activating and Deactivating Environments
Pipenv automatically activates the virtual environment when you use `pipenv shell`.
This creates a forked subshell where the environment is active. To deactivate the environment,
simply exit the subshell by typing `exit` or pressing Ctrl+D.
If you wish to reactivate the environment within the same shell, you can use the `--anyway` flag with `pipenv shell`:
```bash
pipenv shell --anyway
|
Issue description
When deactivating a virtual environment created by
pipenv shell
and then trying to reactivate it usingpipenv shell
, I receive the error:However, running
unset PIPENV_ACTIVE
resolves the issue. Modifying thedeactivate
function in the virtual environment'sactivate
script to includeunset PIPENV_ACTIVE
also works.Expected result
The virtual environment should reactivate without errors when running
pipenv shell
after deactivating it.Actual result
The error message is displayed, and the virtual environment is not reactivated.
Steps to replicate
pipenv shell
.deactivate
command.pipenv shell
.System details
Additional information
To resolve the issue temporarily, adding
unset PIPENV_ACTIVE
to thedeactivate
function in the virtual environment'sactivate
script works. However, this seems to be an issue with pipenv itself.pipenv_support.md
The text was updated successfully, but these errors were encountered: