Create a Virtual Environment in Python on Windows

please click here for more wordpress cource

Sure, here’s how to create a virtual environment in Python on Windows:

  1. Open a Command Prompt window: Press Windows + R on your keyboard to open the Run dialog box, type cmd and press Enter.
  2. Navigate to the directory where you want to create the virtual environment: Use the cd command to change directory. For example, if you want to create the virtual environment in a folder named myenv on your desktop, you would use the following command:
cd C:\Users\YourUsername\Desktop\myenv

Create a virtual environment: Use the python command to create a virtual environment with the venv module. Specify the name of the virtual environment folder that you want to create after the python -m venv command. For example, to create a virtual environment named myvenv, you would use the following command:

python -m venv myvenv
  1. Activate the virtual environment: To use the virtual environment, you need to activate it first. Use the following command to activate the virtual environment:




myvenv\Scripts\activate.bat

You should see the name of the virtual environment in parentheses before the prompt in the Command Prompt window.

That’s it! You have now created and activated a virtual environment in Python on Windows. You can now install packages and run Python code in the virtual environment without affecting the global Python installation on your system. To exit the virtual environment, simply run the deactivate command.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *