This content originally appeared on DEV Community and was authored by Gaurav Pande
This Post guides you through how to setup a python development environment on Windows Sub-System for Linux(wsl2).
What is WSL2?
wsl2 lets a windows user use a virtual linux environment on Windows Machine itself. This is pretty handy feature for quick development needs on your local machine.
Below Steps would list what all are the pre-requisites for achieving a python development environment on Windows Machine:
Installing WSL2: https://learn.microsoft.com/en-us/windows/wsl/install
Install Microsoft Visual Studio code for Windows platform: https://code.visualstudio.com/
Install the Remote WSL Extension on VSCode: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl
Once Wsl2 (at step 1) in installed open an Ubuntu terminal and verify if Python3 is installed using
python3 --version
.If Python3 is not installed then do the following:
sudo apt update
sudo apt install python3 python3-pip python3-venv
NOTE : Above command will install python3 , pip tool and python virtual environment package.
- To create a Virtual Environment Open the WSL2 Terminal and create your python project directory using command
mkdir <YOUR_PROJECT_NAME>
and then inside it runsource .venv/bin/activate
to activate the Virtual Environment where .venv is your virutal environment name.
NOTE: Recommendation is creating the virtual environment inside the directory in which you plan to have your project. Since each project should have its own separate directory, each will have its own virtual environment, so there is not a need for unique naming
- To exit from virtual environment run on wsl2 terminal:
deactivate
Reference: https://learn.microsoft.com/en-us/windows/python/web-frameworks
This content originally appeared on DEV Community and was authored by Gaurav Pande
Gaurav Pande | Sciencx (2024-06-30T15:31:48+00:00) Python Development Environment on WSL2. Retrieved from https://www.scien.cx/2024/06/30/python-development-environment-on-wsl2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.