3

I'm using VScode on windows, and the VScode terminal. I installed virtualEnv (with >>> pip install virtualenv )and everything was working correctly. Then I installed git, and after this, I couldn't deactivate the virtual environment and I don't see any errors too! I use this command: MyVirtualEnvName\scripts\deactivate

my problem is: now I can't deactivate virtualenv and the above command isn't working! how can I deactivate this?

2
  • Do you mean deactivate virtualenv? if you want to deactivate the venv just turn off the terminal session. Commented Aug 10, 2022 at 17:53
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Aug 10, 2022 at 18:12

5 Answers 5

12

try just deactivate in the shell, instead of the path to the deactivate script

1
  • 1
    This worked for me, including in venvs where there was no native bin/deactivate script. Commented Jul 23, 2023 at 2:28
4

There seems to be a bug, if u try to deactivate with .\deactivate.bat it doesn't work but with a plain 'deactivate' without quotes, it works. click to know more

1
  • Same problem deactivate failing. And this solutions works. Who would have guessed that I have to override Powershell's auto expand of 'deactivate' to '.\deactivate.bat' . +Upvote.
    – jim
    Commented Mar 8 at 16:16
1

Go inside Scripts folder by running cd command. Then just type deactivate.

It will recognize and will run the deactivate.bat file.

1

In case this save someone else some time! I had the same issue and spend many hours to fix it. Even closing the vscode did not help and (.venv) was always there! I fixed it with source deactivate

In my case when it kept telling me it does not have permission to access deactivate. When I used sudo it could not find deactivate. But I think (just an idea) the issue is some sort of missing or broken link that is only accessible through source, because to activate I also used source .venv/bin/activate

1
  • confirming this method worked for me. Using Ubuntu 24.04 on a 2019 MBA. Thank you Commented Jun 28 at 17:40
0

You can simply deactivate the virtual environment on terminal using the below command,

deactivate

I am using ubuntu 24.04 and it's working. You don't need to pass the virtualenvironment name because it's already there so you don't have to mention it when you're trying to deactivate.!! And if you use your terminal on vscode you need to add source in front of it. Like,

source deactivate
2
  • Welcome to SO! Unfortunately, this is a repeat of a previous answer by Moh
    – Jesuisme
    Commented Jul 4 at 3:08
  • Sorry, I edited it!
    – Arunisto
    Commented Jul 5 at 19:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.