Deactivate a pipenv environment

前端 未结 5 520
情歌与酒
情歌与酒 2021-02-01 16:03

How can I deactivate my pipenv environment?

With other tools I\'ve been able to do something like source deactivate, but that has no affect here.

C

相关标签:
5条回答
  • 2021-02-01 16:19

    Please check this topic for answer from contributor perspective:

    https://github.com/pypa/pipenv/issues/84#issuecomment-275056943

    Spoiler :

    pipenv starts a new shell session with the virtualenv pathing instead of changing the pathing in the current shell session. That is why deactivate does not work. you need to exit the shell session. the exit command or CTRL-d will do the trick.

    0 讨论(0)
  • 2021-02-01 16:22

    UPDATE: See other answers below. As it has been explained, this works for virtualenv, but pipenv works differently.

    Just type deactivate on the command line. See the guide here

    0 讨论(0)
  • 2021-02-01 16:23

    To elaborate on Williams' answer a bit more, the expected workflow is to enter the virtualenv using pipenv shell. When you activate the virtualenv that way, the console output now indicates to use exit:

    Spawning environment shell (/bin/zsh). Use 'exit' to leave.

    Trying to exit the virtualenv with deactivate will leave pipenv in a confused state because you will still be in that spawned shell instance but not in an activated virtualenv.

    0 讨论(0)
  • 2021-02-01 16:28

    Using the shell command exit also works.

    This worked for me when using deactivate still left me with the error:

    Shell for UNKNOWN_VIRTUAL_ENVIRONMENT already activated.
    No action taken to avoid nested environments.
    

    After using exit I could successfully switch pipenv instances. This could well be a bug and I should probably report it.

    0 讨论(0)
  • 2021-02-01 16:37

    First "deactivate" and then "exit" you will get out of the virtual env. As of now this worked for me.

    0 讨论(0)
提交回复
热议问题