Updated: Jun 16
HacLabs is organizing a course on Python, so i thought of creating up a perfect environment which would help you in the long run.
Some points to be noted:
This setup would be done on WSL, or some may refer to it as Linux. I am not saying windows is a bad choice, but while doing some advanced functionalities, you may face issues with windows. So this is a safer, future proof bet.
As for the IDE, I would be showing mainly on VScode, but I would also show you Pycharm too.
Without waiting any further, let's get started.
If you're on Mac Os:
Install Python (link below)
Install VSCode (link below)
Install Pip, and git, and the bonus (if you want)
[ I do recommend you to install both on Windows and on WSL]
" ➜ " This indicares start of the terminal
Although I was thinking to make this totally about WSL, this is for them who would like to keep things simple.
After you've downloaded, Install Python, you may get an installer like this
Make sure to check both the boxes below, and don't leave it unchecked as given above! If you did, reinstall again.
To confirm if python is properly installed, go to cmd and type in:
➜ python --version or, ➜ python3 --version Output: Python 3.8.3 (or something similar)
P.S. at this stage remember if python or python3 works for you. This depends on system to system. I will use python3 as it works for me, but use python if it works for you.
Do install Pycharm or VSCode as intended.
If you're using Pycharm, running python has 2 ways.
Right-click and run
Press the play button (this would work only when you have the main function)
You do need to download git, install and the commands to follow to set up git completely are given below. Pycharm does handle the rest so relax and follow along.
For VSCode users, we will cover it in the WSL section.
WSL or Linux
This has always been my preferred setup, and I will be following this setup on most courses. So follow along.
Installing WSL with zsh
If you're a Linux user, you may skip this.
Open Powershell as Administrator, copy the code below and paste it in
➜ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
This will install WSL on your system.
Restart your PC once, and then press the Windows key, select Ubuntu and go through the basic setup. Do remember the password you type in there.
Now, open Windows Terminal and you should see something like this
Congrats, you've installed Linux, but we're still not done.
Before we continue, Install VSCode on your system
➜ sudo apt install zsh ➜ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" The following commands are optional, for styling purposes only. You can ignore them ➜ sudo apt-get install fonts-powerline ➜ code ~/.zshrc # to customize it
Type in the commands in your Ubuntu Terminal. Avoid the last command if you don't want to customize it. Set ZSH_THEME="random", this will generate random themes, if you like one, type in the last command, and set ZSH_THEME="<theme name>"
In VSCode extension store, you'll find something called Remote WSL. Install it, also it may pop up on recommendations in VSCode.
Optional for WSL
➜ sudo apt install git ➜ git --version ➜ git config --global user.name "Anish Bhattacharya" ➜ git config --global user.email "email@example.com" ➜ git config --global credential.helper cache --timeout=3600
Installing Python on Linux and WSL
So installing python is super easy.
➜ sudo apt-get install python3
Although, chances are python is already installed. Check using,
➜ python3 --version or, ➜ python --version
P.S. at this stage remember if python or python3 works for you. This depends on system to system. I will use python3 as it works for me but use python if it works for you.
This should be followed by everyone, regardless you installed on Windows or Linux.
➜ sudo apt install python3-pip #for linux # Download get-pip.py # navigate to get-pip.py and run ➜ python3 get-pip.py
To check if pip is installed
➜ pip3 --version pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) (if this doesn't work try pip instead of pip3)
VSCode extensions Search for them on the extension tab:
Python for VSCode
Python Extension Pack
Indent-Rainbow (This will make your python development easier)
Bracket Pair Colorizer 2
Prettier (It makes your code pretty)
GitLens (If you plan on using GitHub)
Install these and you will have an amazing time developing python code.
Integrating Pycharm with WSL
Integrating Pycharm with WSL is as easy as it seems.
Go to Settings >> Tools >> Terminal, and in shell path, just write wsl.exe A reference screenshot is given below
Now, you've WSL access directly from Pycharm
Now, setting up your Python Development environment is done. Phew! If you have any questions, or you feel like I missed something, comment below, and I will surely get back to you.