To deactivate a virtual environment in Python, you can use the deactivate command. This is a shell command, not a Python command, so you'll need to run it from the command line or terminal. After running this command, you should see the command prompt change, indicating that you are no longer in the virtual environment.
Alternatively, you can also use the exit command to exit the virtual environment. This will also close the terminal window or exit the command prompt, depending on your operating system.
$ exitIf you are using a Python shell or interactive interpreter, you can simply close the window or exit the interpreter to deactivate the virtual environment.
It's also worth noting that if you are using a Python script to manage your virtual environments, you can use the exit() function to exit the script and deactivate the virtual environment.
import sys sys.exit()
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.