1. Installing Python and Setting Up Your Development Environment#
There are several alternatives for installing Python and getting started quickly:
Direct Installation: Download and install Python from Python.org.
Bundle Environments: Use user-friendly packages like the Anaconda distribution that come with numerous pre-installed libraries.
Cloud-Based Notebooks: Skip local installations altogether and use online environments like Google Colab—perfect for instant access and collaboration.
Local Integrated Development: Set up a local development environment using editors such as Visual Studio Code with integrated tools like GitHub Copilot for AI-powered coding assistance.
Each approach has its advantages and drawbacks. Personally, I started with Anaconda because it provided a comprehensive ecosystem with many libraries at your fingertips. However, I now often lean towards using a “pure” Python installation managed via Pip for maximum flexibility and timely library updates. But for many beginners—and for fast prototyping—online environments like Google Colab are unparalleled.
1.1. Google Colab#
Probably the easiest and most effortless way to start practicing Python is to use Google Colab. With Colab:
No Installation Required: If you have a Google account, simply head to colab.google.com, open a notebook, and begin coding immediately.
Free Cloud Compute: Leverage powerful hardware (including GPU and TPU support) directly in your browser for data science and machine learning projects.
Seamless Sharing: Easily share your notebooks with peers for collaboration without worrying about installation issues.
For many beginners and even experienced data scientists looking to prototype quickly, Google Colab is the preferred option.
1.2. Visual Studio Code with GitHub Copilot#
For those who prefer a robust local development setup, Visual Studio Code offers a flexible, lightweight editor with phenomenal extensions. With VS Code you get:
Integrated Terminal and Debugging: Streamline your coding workflow with built-in tools.
GitHub Copilot Integration: Benefit from AI-driven code suggestions and autocompletion that help accelerate coding and reduce boilerplate.
Version Control and Extensions: Easily integrate with Git and customize your editor to fit your project needs.
This combination delivers an efficient, powerful coding environment that rivals cloud-based alternatives.
1.3. Anaconda#
If you want a complete Python environment installed on your computer, Anaconda remains a popular choice:
All-Inclusive Ecosystem: Anaconda comes pre-loaded with many libraries essential for data science and machine learning, reducing setup time.
User-Friendly Management: With Anaconda Navigator, you can manage packages and environments with a click-and-point interface, bypassing much of the command line complexity.
Cross-Platform Uniformity: The experience is consistent across Windows, macOS, and Linux.
To install Anaconda, simply download the binaries from Anaconda Individual Edition and follow the on-screen instructions. During installation, choosing to set Anaconda as your default Python environment is recommended for beginners to avoid potential conflicts.
1.4. Installing Anaconda#
To install Anaconda, you just need to download the binaries from www.anaconda.com/products/individual and follow the instructions. Remember to install the latest version. During the installation, you are asked whether you’d like to make Anaconda your default Python environment. You should definitely answer yes to avoid difficulties later. (Notice that if you plan to install also pure Python, then you do not necessarily want to make Anaconda your default environment. However, if you are learning Python, it is strongly discouraged to hassle with many Python installations. It is like asking for trouble.)
1.5. Updating Anaconda#
Anaconda uses Conda (conda.io) to manage libraries and packages. You do not necessarily need to learn Conda commands, as you can do (almost) everything in Anaconda just by pointing and clicking. However, one command you should execute regularly is conda update anaconda. It keeps your Anaconda environment updated.
For more information on Conda, go to docs.conda.io.
1.6. Installing pure Python#
If you still, despite my warnings, want to install pure Python, then follow these instructions. (Just kidding :). There are benefits of using pure Python, as I mentioned earlier.)
For windows, follow these steps: docs.python.org/3/using/windows.html#installation-steps
Python comes preinstalled on most Linux distributions and is available as a package on almost all others. If this is not the case for your Linux, follow these steps: docs.python.org/3/using/unix.html#on-linux
1.7. Environments#
Whether you use Anaconda or pure Python, you should definitely learn to use environments. This way, you can install only the libraries needed for the current task, and other unnecessary libraries are not breaking the environment.
The instructions to create and activate environments in pure Python are here: docs.python.org/3/tutorial/venv.html
And for Anaconda, here: docs.anaconda.com/anaconda/navigator/tutorials/manage-environments/
If you want to use Conda at the terminal, follow these instructions: docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
1.8. Jupyter notebook#
Jupyter notebooks are one of the many possible ways to interact with Python and its scientific libraries.
They use a browser-based interface to Python with
The ability to write and execute Python commands one command at a time.
Observe output in a formatted form, including tables, figures, animation, etc.
Add formatted text (Markdown) between the Python commands. It also supports mathematical expressions with MathJax.
Jupyter is nowadays an extremely popular environment for data science and scientific computing. Almost always, data science examples that are available on the Internet are in the form of Jupyter notebooks.
While Jupyter isn’t the only way to code in Python, it’s great for
beginners
quick testing
sharing code
By the way, this book is written with Jupyter notebooks.
1.9. Starting Jupyter notebook#
Once you have installed Anaconda, you can start the Jupyter notebook either
by searching for Jupyter in your applications menu,
or opening up a terminal and typing jupyter notebook.
In Windows, you need to open the Anaconda command prompt for the previous line to work.
The first option will always open Jupyter automatically. On some platforms, the second option will output an address that you need to write to your browser for Jupyter the open. This is always the case if you are using Jupyter in a server environment.
There is also Jypterlab that is an advanced version of Jupyter. You can start it from the Anaconda menus or by writing jupyter-lab.
That’s it! Now you have a working Python environment, and you can start coding.