General-purpose programming language. Easy to learn, widely used for AI/data science. Free to download, free packages, it’s awesome
Install Python
- Download the latest version of Python from python.org/downloads
- Check “add to PATH” during install
- Note, if you download python and it doesn’t run, it’s most like because the python executable file is not in your PATH variable.
- Open a terminal and type
python --version
to verify installation- Some systems require you to type
python3
to run python, annoying.
- Some systems require you to type
Run Python code
- Create a file with the .py extension, e.g.
test.py
- Use a text editor to write code in test.py, e.g. you could add:
print("hello world!")
<– that’s python code right there
- Use a text editor to write code in test.py, e.g. you could add:
- In the terminal, navigate to the folder that contains test.py
- Run
python test.py
in the terminal to execute the python script.
Install Python packages
- NOTE: A package is an extension of Python that adds more functionality. Most packages only really do 1 or 2 things and aren’t very hard to learn.
- In a terminal, run the command
pip install name
, and replace name with the name of the package you want, which is often different from the marketing name of the package. Here are some solid starter packages for data analysis:pandas
= for importing data (in .csv, etc) and using itnumpy
= put imported data into an array/matrix and manipulate itmatplotlib
= for plotting graphsscipy
= has fancy math equationstorch
= huge package has all the modern AI/ML stuff (this is PyTorch)