- Create a project/folder in workspace in VS Code
- Open the Terminal and run the below command to create virtual env
python -m venv env - A new folder named env will
- Now we have to activate the virtual env using below command
./env/Scripts/activate - Now virtual env is activated we can see it in our command prompt as below
now we can run our application for example if its a Flask
flask run
Extras
- If we want to install requirement.txt we can run below command
pip install -r .\requirements.txt - if we want to create requirement.txt we can use below command
pip freeze > requirements.txt - If we want to create a .ignore file we can use below command
touch .gitignore
if this command is not working in command prompt you can use git bash window it should work there
(why do we create .gitignore file – if we don’t want to include any file or folder in check-in to github in that case we can create this file and we can include the file or folder name into that)
Example – inside the .gitignore file we can mention env/ folder because we don’t want it to be included in github repository - we can run our flask application in command prompt as well instead of browser using below command
curl -i -X GET http://localhost:5000/
or
curl http://127.0.0.1:5000