Python IDE Setup

Python IDE Setup


  Machine Learning in Python

Summary Almost all professionals use some sort of IDE to write, debug and test their code on. Data Scientists and Machine Learning experts are no different. While there are a whole host of choices, we will focus on just a couple. Feel free to pick any IDE you feel comfortable with.

Contents

Visual Studio Code

Developed by Microsoft and available for free in both Windows and Mac environment, Visual studio code is a good editor for Python. Go to Visual Studio Code and click on the download link. Your download should start automatically. Double click the executable and you should be able to install Visual Studio code with the Wizard pretty easily.

Select a folder where you want all your files to be, say create a demo folder in your Documents folder. In Visual studio code, open that folder and you can now start creating python files.

Demo-Visual Studio Code
Demo-Visual Studio Code

Give it a name hello_world.py

Demo-Visual Studio Code
Demo-Visual Studio Code

As you can see already, this is much better than IDLE.

Hello World
Hello World

It has line numbers, a neatly organized file structure ( on the left ), syntax highlighting and of course much more. To execute the file, right click and select Run Python File in Terminal in the context menu.

Run Python File in Terminal
Run Python File in Terminal

You can see the file getting executed and see the results in the in-built terminal.

Output
Output

Visual Studio Code is a generic IDE built for a variety of programming languages. To enable it specifically to the needs of python ( like python syntax highlighting etc ), you have to install the python extension. Click on the Settings wheel on the left bottom corner and select Extensions.

Extensions
Extensions

type in Python and select the Python package.

Python 2018.11.0
Python 2018.11.0

Click on install to install the Python extension.

Install Python Extension
Install Python Extension

You can either restart Visual Studio Code or click on Reload to Activate button and you should be all set for basic python programming in visual studio code.

Activate
Activate

And by the way, we like the dark theme. You can very well have any theme you like. Go to File -> Preferences -> Color Theme

Preferences -> Color Theme” class=”wp-image-737″/>
Go to File -> Preferences -> Color Theme

and select any theme you like.

Theme
Theme

Sublime Text

Sublime text is another popular text editor. It is free for evaluation but you would have to buy it. The one key advantage of sublime text is that it is blazing fast. Download Sublime Text editor here. Installing it is just as easy as visual studio code. Enabling the packages ( like extensions in Visual studio code ) is just as easy. We will not go into the details here.  

Jupyter Notebook

Jupyter notebook is a very interesting IDE. In fact it is not an IDE – but more of a teaching/learning/sharing tool. Jupyter is used extensively in the data science world to illustrate research results – and as a learner you should know how to install and run Jupyter files. We will be using Jupyter extensively throughout this course. Once you have python installed, installing Jupyter is very easy.

Go to the command prompt and type in

 pip install jupyter 

once installed, type in

 jupyter notebook 

This should start a jupyter notebook on your default browser in the directory where you started the command. Just make sure you don’t close the command window.

jupyter is best installed with Anaconda installation ( That is the recommended approach ), but you can do it this way as well.

This also shows the power of pip , the default python package manager. More on this later.

Jupyter Lab

Jupyter lab is the next version of Jupyter notebook. It has a better UI than the regular Jupyter notebook. Installing it is just as easy.

pip install jupyterlab 

To run jupyter lab, go to the directory where you want to write your code, just type in

jupyter lab 

And this is the interface that you see.

 Python 3 notebook icon
Python 3 notebook icon

Click on File -> New -> notebook or click on the Python 3 notebook icon. A new .ipynb file will be created and ready to go.

new .ipynb file
new .ipynb file

You can start your “Hello World” program here as well.

"Hello World" Program
“Hello World” Program

And you see the program output right there.

Output
Output

Let’s write our first real program on Visual Studio code in the next section. 

Google Colab

Google’s colab is another popular option to run your programs on the cloud. Click here to go to Google’s colab URL. Click on File-New Python 3 Notebook.

select new python notebook

Make sure you are connected to a run-time.

connect to a cloud runtime

And that’s it, you can start working on your Python code.