Table of Content
This post is a part of Learning Path, Python for Programmers.
People who are following the learning path plan have different backgrounds and experiences. Setting the environment and working with IDEs is their own personal choice.
However, I am providing commands and a setup process that will help people who are just getting started.
Core Requirements
- A little familiarity with the command line, run code, install packages, use git commands, etc.
- A Python interpreter, version>=3.8
- A text editor to edit your code.
If you have already set up your environment, I would recommend you to skip to the last part where I have provided testing codes to test the setup.
If not, read on.
Development Environment
When working with Python you need,
- A command line
- An Interpreter
- An Editor
- Source Code Version Control System i.e. git
Installing Python
Python can run on all operating systems, including macOS or Linux, or Windows. Python is an interpreted language, which means we need to have an interpreter to run any python script.
You can find different Python interpreters, each has its own use cases,
- cPython
- Jython
- Iron Python
- PyPy
The most commonly used interpreter in the production system is cPython.
Setting up macOS
Terminal
You can find the terminal application under, /Applications/Utilities/Terminal
folder.
Python
macOS comes with Python pre-installed but we will set up and upgrade to the latest version.
Download the latest release of Python installer from Python.org:
https://www.python.org/downloads/
Click and follow the steps.
When the installation process is completed, Python is installed as /usr/bin/python3
.
Running python3
in terminal gives us,
Remember, don't get confused by running the python
command on your system that points to the old Python 2.
If we want to get python3
by simply typing python
in the terminal, we need to add an alias in the .bashrc
or .bash_profile
file in the home folder.
Add below line to the file,
alias python="python3"
Once done, you should be able to type python
and get the latest version you have installed.
This is the Python interpreter.
To exit the interpreter use the below command inside of interpreter or press ctrl + D
,
exit()
pip
pip
is the Python Package Installer. It's installed with python setup and we want to update pip.
python -m pip install --upgrade pip
Using pip
To install any package use the below command,
python -m pip install <name_of_the_package>
iPython
One of the packages we will use is iPython
. You can install it using,
python -m pip install ipython
You should be able to see,
Git
Git is a source code version control system.
What does it mean?
Git is used to storing content(code). And we change our code from time to time as per the requirements. Therefore a version control system maintains a history of what changes have happened.
This is a very critical tool for software development and is widely used. In real life, multiple developers work on a single project in parallel. So Git ensures there are no code conflicts between the developers.
This link below has details on how to install Git:
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Verify if git is installed by using,
git --version
Editor
I would recommend using Visual Studio Code provided by Microsoft.
You can download it from here,
https://code.visualstudio.com/
Testing our tools
To test out your setup, run the commands and get something similar to the images.
Python testing
iPython testing
pip testing
git testing
If those commands all run – you are all set!