Installing Python on your computer allows you to run Python code. Python is an interpreted high-level programming language with simple syntax.
You can install Python on MacOS by following these steps:
You have successfully installed Python on your computer. To open IDLE, search for "IDLE" in Spotlight search or find it in Launchpad. To open IDLE from the terminal, type:
idle3
By default, IDLE opens in the Shell window, which allows you to run Python commands interactively, but does not provide an interface for writing longer scripts efficiently.
When IDLE is launched, it usually opens in the Shell window by default. The Shell window allows you to type and execute Python commands interactively. However, it is not ideal for writing longer scripts, as it does not allow saving or editing multiple lines of code easily.
To make IDLE open in the Edit window each time, follow these steps:
Now, every time you launch IDLE, it will open in the Edit window where you can write and save scripts easily.
If you prefer opening the Edit window manually, you can do so by:
This will allow you to start writing and saving Python scripts with ease.
Command Line Tools for Xcode are essential for compiling and running development tools, including Python.
They provide UNIX command-line utilities such as gcc
, git
, and make
, which are needed to run Python in Visual Studio Code.
xcode-select --install
xcode-select --version
If you see a version number displayed, the installation was successful.
Installing packages allows you to use code written by others. You can install them by following these steps:
pip3 install [insert package name(s) here, without the square brackets]
For example, to install all the packages needed for CSCI 127 at Hunter College, type:
pip3 install numpy image matplotlib scipy pandas folium
You have successfully installed Python packages.
Visual Studio Code (VS Code) is a popular code editor with features that enhance Python development. Follow these steps to install and set it up:
python3 --versionto check if Python is recognized.
print("Hello, Python in VS Code!")
Click the "Run" button (located in the tool bar near the top right of the VSCode window)
OR
Use Cmd + Shift + B to execute the script.
You have successfully set up Python in Visual Studio Code!
Author: Georgina Woo