System: Windows ; IDE: VS Code
Step 1: Create a folder.
Step 2: Launch Command Prompt
Step 3: Navigate to your folder by writing the command: cd (copy paste the absolute path to the folder)
Step 4: Check if you’re in the folder then write the command: python -m venv .venv
(This will create the .venv folder inside your project folder.)
Step 5: Then type from Command Prompt: .venv\Scripts\activate.bat
(This will activate the virtual environment.)
Step 6: In case, you want to work with any .py or .ipynb file, place them inside your project folder.
Step 7: Now open your project folder from VS code: File > Open Folder > Select your project folder
Step 8: Now click on the file you want to work on by selecting it from the folder.
Step 9: On the top right corner of the file (on the same line as ‘code’ ‘markdown’ ‘run all’…) if it appears : ‘.ven(python version) then it’s all good. Otherwise, click on ‘select kernel’ and choose the python interpreter that looks like ‘.venv\Scripts\python.exe
‘.
Step 10: If kernel doesn’t appear then from Command Prompt (with venv activated) try: pip install ipykernel
Step 11: To deactivate simply type: .venv\Scripts\deactivate.bat
(This will deactivate the virtual environment.)