Select Page

A step-by-step guide on installing setting up VS Code, PowerShell, Python, Git, GitHub, and virtualenv. With pictures!

One of the roadblocks of learning data science or any programming, in general, is setting up the development environment on the local machine. So I’ve decided to buy a brand new computer to use solely for documenting the steps I took in setting up my development environment.

Today, we’ll be going through the steps of downloading, installing, and setting up some of the most common tools used in data science projects. We’ll be covering:

  • Visual Studio Code
  • PowerShell
  • Python
  • Virtualenv
  • Git
  • GitHub

For today’s guide, we’ll be using a Lenovo laptop with the following specifications:

Processor: Intel i3–10110U CPU @ 2.10 GHz
Installed RAM: 8.00 GB
System Type: 64-bit OS
Operating System: Windows 10 Home

Without further ado, let’s get started.

Setting Up Visual Studio Code

Let’s open up a Google Chrome web browser window and go to https://code.visualstudio.com.

Screenshot by Ednalyn C. De Dios

Click on the giant blue button to VS Code “Download for Windows.”

Screenshot by Ednalyn C. De Dios

Proceed to download the installer in the “Downloads” folder.

Screenshot by Ednalyn C. De Dios

After it’s downloading, double-click on the installer program.

Screenshot by Ednalyn C. De Dios

Let’s accept the agreement and click “Next.”

Screenshot by Ednalyn C. De Dios

Accept the defaults by clicking on the “Next” button several times.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

Make sure the box to “Add to PATH …” is checked.

Screenshot by Ednalyn C. De Dios

Optional, but I figured it’s beneficial to include the “Open with Code” actions to both Windows Explorer file and directory context menus.

Screenshot by Ednalyn C. De Dios

Hit “Next” one more time and click on “Install.”

Screenshot by Ednalyn C. De Dios

When the installer finishes installing, just click on “Finish.”

Screenshot by Ednalyn C. De Dios

At this point, a VS Code window will open and presents us with an option to change the color theme.

Screenshot by Ednalyn C. De Dios

I like the color blue, so I decided on the “Deep Blue” theme by Julian Kaindl.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

After the changes take effect, let’s go ahead and close the “Get Started” and the Extensions page by clicking on the “x” and extensions icons.

Screenshot by Ednalyn C. De Dios

Find the “Terminal” menu on the top of the application and select “New Terminal” as shown below.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

We will be working a lot on the terminal in the future, so it’s handy to know the keyboard shortcut for this: CTRL + Shift + `.

Customizing PowerShell

Every time we open a new PowerShell terminal, a little advert for PowerShell shows up, and it’s quite annoying. Let’s change it!

Type in the following at the Terminal prompt:

notepad $PROFILE
Screenshot by Ednalyn C. De Dios

Notepad will then notify you that it cannot find the ps1 file. Click on “Yes” to create one.

Screenshot by Ednalyn C. De Dios

A blank notepad file will pop up.

Screenshot by Ednalyn C. De Dios

Copy and paste the following into the file:

https://medium.com/media/5cc8b3ba146daf9b27a109f662642770

cls tells the computer to clear the screen of the default prompt and Write-Host 'XXX' displays XXX into a line on the screen. You can change the code above to suit your taste. Set-location "XXX..." sets the default directory and function prompt "XXX $(get-location)>" controls what the terminal prompt will look like.

Save the file.

Screenshot by Ednalyn C. De Dios

The result is shown below.

Screenshot by Ednalyn C. De Dios

Installing Python

Next on our itinerary is downloading and installing Python. Let’s head on over to https://python.org/downloads.

Screenshot by Ednalyn C. De Dios

I don’t recommend downloading the latest build yet because I like to be conservative and opt for an earlier version that most packages support. Scrolling down the page, we’ll see our favorite, the 3.9.9 release version.

Screenshot by Ednalyn C. De Dios

Click on “Download.”

Screenshot by Ednalyn C. De Dios

Scroll down and click on “Windows Installer (64-bit).”

Screenshot by Ednalyn C. De Dios

Save it in the “Downloads” folder.

Screenshot by Ednalyn C. De Dios

And double-click on the installer program to start the installation.

Screenshot by Ednalyn C. De Dios

Make sure you check “Add Python 3.9 to PATH” and click on “Customize Installation.”

Screenshot by Ednalyn C. De Dios

Make sure all the boxes are checked before clicking on the “Next” button

Screenshot by Ednalyn C. De Dios

Click on the “Install” button.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

When it’s done installing, it might show you the option to “Disable path length limit,” click on it.

Screenshot by Ednalyn C. De Dios

Click “Close.”

Screenshot by Ednalyn C. De Dios

To verify that Python 3.9 was correctly installed, let’s fire up a new terminal on VS Code and type:

python --version

It should say “Python 3.9.9.”

Screenshot by Ednalyn C. De Dios

Installing Virtualenv

I use a different virtual environment for each of my data science projects. 

Athreya Anand

 has a good explanation of “Why you should a virtual environment for EVERY python project!

Let’s go back to our terminal and type the following:

pip install --user virtualenv
Screenshot by Ednalyn C. De Dios

If it gives you a warning like below:

Screenshot by Ednalyn C. De Dios

it means we need to add the directory to the PATH in our environment variables.

Screenshot by Ednalyn C. De Dios

Let’s take note of the directory where virtualenv was installed.

Screenshot by Ednalyn C. De Dios

Then, click on the start at the bottom-left area of your Windows desktop and click on the gear icon for “Settings.”

Screenshot by Ednalyn C. De Dios

We will see a screen similar to the one below.

Screenshot by Ednalyn C. De Dios

At the search box in the middle of the screen, type in “env” and click on the first dropdown option, “Edit environment variables for your account.”

Screenshot by Ednalyn C. De Dios

On the next screen, click on “Edit…” as shown below.

Screenshot by Ednalyn C. De Dios

Next, click on the “New” button.

Screenshot by Ednalyn C. De Dios

Type in the directory where virtualenv was installed and click on the “OK” button.

Screenshot by Ednalyn C. De Dios

Click “OK” one more time, and we’re golden!

Screenshot by Ednalyn C. De Dios

Setting up Git & Github

Let’s head to https://git-scm.com/downloads and click on the green “Download for Windows” button.

Screenshot by Ednalyn C. De Dios

Click on the “Click here to download” link to download the latest version of Git for Windows.

Screenshot by Ednalyn C. De Dios

Save it on the “Downloads” folder.

Screenshot by Ednalyn C. De Dios

Double-click the installer.

Screenshot by Ednalyn C. De Dios

Click “Next.”

Screenshot by Ednalyn C. De Dios

Click “Next” to accept the default installation location.

Screenshot by Ednalyn C. De Dios

On the next screen, uncheck the two boxes underneath “Windows Explorer Integration.”

Screenshot by Ednalyn C. De Dios

Then, click “Next” two more times.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

Change the default editor by clicking on the dropdown arrow as shown below.

Screenshot by Ednalyn C. De Dios

Select “Visual Studio Code as Git’s default editor” and click on “Next.”

Screenshot by Ednalyn C. De Dios

Select the second option to set the default branch name to “main” instead of “master.”

Screenshot by Ednalyn C. De Dios

Click “Next.”

Screenshot by Ednalyn C. De Dios

Click on “Next” several more times.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

And finally, click on the “Install” button to start the actual installation.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

Once the install process finishes, ensure the “Launch Git Bash” is checked and click on “Finish.”

Screenshot by Ednalyn C. De Dios

On the terminal window that launches (this is the Git Bash), type in:

git config --global -user.name "YOUR NAME HERE"

(Ensure you replace “YOUR NAME HERE” with your name.)

Next, type the following to set the email.

git config --global user.email "YOURNAME@EMAIL.COM"

(Similarly, replace “YOURNAME@EMAIL.COM” with your own.)

Screenshot by Ednalyn C. De Dios

Next, we will generate a public/private key pair for SSH. On the terminal, type in:

ssh-keygen -t ed25519 -C "YOURNAME@EMAIL.COM"

Don’t forget to replace “YOURNAME@EMAIL.COM” with your name.

When asked for the file with which to save the key, just hit the ENTER key to accept the default.

Screenshot by Ednalyn C. De Dios

When asked for the password or passphrase, hit the ENTER key twice.

Screenshot by Ednalyn C. De Dios
Screenshot by Ednalyn C. De Dios

It should then generate the random art image for the key, as shown below.

Screenshot by Ednalyn C. De Dios

Next, we’re going to add the key to the ssh-agent. Type in:

eval "$(ssh-agent -s)"
Screenshot by Ednalyn C. De Dios

It should say “Identity added….”

Screenshot by Ednalyn C. De Dios

Next, we’re going to copy the key to the clipboard. Type in:

clip < ~/.ssh/id_ed25519.pub
Screenshot by Ednalyn C. De Dios

For this next part, we need to go to Github’s settings.

Screenshot by Ednalyn C. De Dios

Under the “Access” section, look for “SSH and GPG keys.”

Screenshot by Ednalyn C. De Dios

We will see something like the one below. For the next step, click on the green “Run SSH key” button.

Screenshot by Ednalyn C. De Dios

On the next screen that follows, let’s paste the contents of the clipboard (CTRL+V) and then click on the green “Add SSH key” button at the bottom of the large text box.

Screenshot by Ednalyn C. De Dios

At this point, we need to test if git was installed properly and also if our Github setup worked.

Let’s open a new windows explorer window and navigate where you usually store your code. Then, right-click somewhere and create a new folder for our test project.

Screenshot by Ednalyn C. De Dios

For this time, let’s name it “test-github-setup.”

Screenshot by Ednalyn C. De Dios

For the next part of the process, we will create a new repository on Github and grab the SSH information that is provided. So, head on to your Github repositories and click the green “New” button as shown below.

Screenshot by Ednalyn C. De Dios

Let’s give it a name and add a description.

Screenshot by Ednalyn C. De Dios

Scroll down, and click on the green “Create repository” button.

Screenshot by Ednalyn C. De Dios

On the next page that appears, ensure that SSH is selected and click the copy icon on the right of the textbox.

Screenshot by Ednalyn C. De Dios

Then, let’s switch to our terminal and type in the following:

git remote add origin PASTE_IN_THE_SSH_INFORMATION_HERE

Don’t forget to replace PASTE_IN_THE_SSH_INFORMATION_HERE with the information we copied in the previous step. It should be something like git@github.com:username/repository-name. git.

Screenshot by Ednalyn C. De Dios

Let’s now switch to a Windows Explorer and navigate to the location of our local repository and confirm that nothing else exists on the folder except the .git folder.

Screenshot by Ednalyn C. De Dios

Next, type in the following on the terminal:

git pull origin main

If you get a message that says, “The authenticity of host ‘github.com… can’t be established…” type in “yes” as a response.

Screenshot by Ednalyn C. De Dios

You should then get a warning message like the one below.

Screenshot by Ednalyn C. De Dios

To test our connection to the remote Github repo, let’s create a new text document in the folder as shown below.

Screenshot by Ednalyn C. De Dios

Name it test.txt and switch to the terminal.

Screenshot by Ednalyn C. De Dios

On the terminal, type in:

git push -u origin main
Screenshot by Ednalyn C. De Dios

On your Github page, click the refresh icon on the browser, and let’s see what happens next!

Screenshot by Ednalyn C. De Dios

Instead of the setup page, we now should see the “test.txt” document that we created on the local machine (repo).

Screenshot by Ednalyn C. De Dios

Bonus Round

Remember the Windows PowerShell Profile that we created earlier? Navigate to the C:\Users\Dd\OneDrive\Documents\WindowsPowerShell folder, open Microsoft.PowerShell_profile.ps1 and add the following to create some shortcut commands.

https://medium.com/media/4c8228552489e7db7f2b7a823bbbad1d

The code above sets some shortcut commands that replace long-winded ones. For example, instead of typing jupyter notebook (you have to pip install notebook first!), simply type jn and you’re good to go!

Similarly, instead of typing git init type in gii instead. Here are the other git commands:

  • gii: git init
  • gss: git status
  • gaa: git add .
  • gcc COMMIT_MESSAGE: git commit -m COMMIT_MESSAGE
  • grr SSH_INFO: git remote add origin SSH_INFO
  • gpush: git push -u origin main
  • gpull: git pull origin main

Because I’m really lazy, I’ve also added the following shortcut for pip installing some of the most often used packages related to data science:

  • pipinit: pip install notebook numpy pandas scipy matplotlib sklearn seaborn scikit-learn

And finally, let’s not forget to ensure that setting up a virtual environment is also a breeze:

  • vnv387: virtualenv v399 -p PATH_TO_PYTHON_387_EXE
  • vnv399: virtualenv v399 -p PATH_TO_PYTHON_399_EXE
  • vnv310: virtualenv v399 -p PATH_TO_PYTHON_310_EXE
  • act387: .\v387\Scripts\activate
  • act399: .\v399\Scripts\activate
  • act310: .\v310\Scripts\activate

And that’s it! We’ve successfully set up our new machine for data science in Python.