On Windows:
Open Command Prompt (CMD), make sure the CMD is set to the folder where your project is, and execute:
py -3 -m venv env
That will create folder named env. To activate the environment execute:
env\Scripts\activate.bat
To use the Python interpreter of your virtual environment execute:
python
On Mac and Linux:
Open Terminal, make sure the terminal is set to the folder where your project is, and execute:
python3. -m venv env
That will create a folder named env. To activate the environment execute:
source env/bin/activate
To use the Python interpreter of your virtual environment execute:
python
On Windows:
C:\Users\YourUsername\Documents\my_project>py -3 -m venv env
C:\Users\YourUsername\Documents\my_project>env\Scripts\activate.bat
(env) C:\Users\YourUsername\Documents\my_project>python
Python 3.x.x (tags/v3.x.x:xxxxxx, date xxxxxx) [MSC v.xxxx 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
On Mac and Linux:
$ cd /path/to/your/project
$ python3 -m venv env
$ source env/bin/activate
(env) $ python
Python 3.x.x (default, date xxxx) [GCC x.x.x] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.