Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

Python Dictionary

  1. Home
  2. Python Dictionary
  3. [Setup] Python Development Environment

[Setup] Python Development Environment

This page explains how to set up a Python development environment. Python is easy to install, and you can run code from the terminal (command prompt) right away.

Installing Python

OSInstallation Method
WindowsDownload and run the installer from python.org. Make sure to check "Add python.exe to PATH" on the installation screen. If you skip this, the python command will not be available in the terminal.
macOSmacOS comes with Python 3 pre-installed. Run python3 --version in a terminal to verify. If you need the latest version, run brew install python with Homebrew. Homebrew is a package manager for macOS — if it is not installed, follow the instructions at https://brew.sh/.

After installation, open a terminal (Command Prompt on Windows) and run the following.

python3 --version
Python 3.12.4

If a version number is displayed, the installation was successful. On Windows, use python --version instead.

Using Interactive Mode (REPL)

Type python3 (or python on Windows) in a terminal to launch interactive mode (REPL). You can enter code one line at a time and see the result immediately, making it ideal for learning.

python3
Python 3.12.4 (main, Jun  6 2024, 18:26:44)
>>> print("Hello, Python!")
Hello, Python!
>>> 1 + 2
3
>>> name = "Gojo Satoru"
>>> print("Hello, " + name + "!")
Hello, Gojo Satoru!
>>> exit()

To exit interactive mode, type exit(), or press Ctrl + D (on Windows: Ctrl + Z then Enter).

Creating and Running a .py File

This method involves writing Python code in a text editor, saving it with the .py extension, and running it. Use this approach for programs with multiple lines.

Save the following content as hello.py using a text editor.

hello.py
name = input("Enter your name: ")
print("Hello, " + name + "!")

for i in range(1, 6):
    print("Loop iteration " + str(i))

print("Program finished!")

Navigate to the folder where you saved the file in a terminal, then run it with the following command.

For macOS / Linux:

python3 hello.py

For Windows:

python hello.py

Recommended Editors

EditorFeatures
VSCodeInstalling the Python extension gives you code completion, debugging, and error highlighting. Free. The full name is "Visual Studio Code".
Sublime TextA lightweight, extremely fast editor. Its simple interface lets you focus on coding. Available on Windows / macOS / Linux.
Hidemaru EditorA legendary Japanese text editor first released in 1993. Lightweight, fast, and equipped with a powerful macro system. Windows only, one-time purchase.
IDLEThe editor bundled with Python. No additional installation needed — ready to use right away.
PyCharm CommunityA Python-dedicated IDE by JetBrains. Packed with advanced features like smart code completion and a built-in debugger. It can be a bit heavy, so it is recommended once you are more comfortable with Python. Free.

These days, VSCode seems to be the most widely used editor, but the webmaster personally loves simple and lightweight editors, so he currently uses Sublime Text. Feel free to use this as a reference.

A note about Hidemaru Editor: first released in 1993, Hidemaru is lightweight, features powerful search and replace with regular expressions, and can be customized with macros. In modern terms, macros are similar to add-ons — and Hidemaru had this capability back in the 1990s, a remarkably forward-thinking design that makes it a truly wonderful editor.

The webmaster himself used Hidemaru Editor for programming from the Windows 3.1 era through Windows 7, and owes a great deal to it over the years. Its developer, Hideo Saito, continues to update Hidemaru to this day — it runs perfectly on Windows 11 and other 64-bit versions of Windows. You can purchase Hidemaru Editor from here — it is a one-time purchase for around 4,000 yen (about $27), and having it on a Windows machine can be surprisingly handy.

(´-`).。oO(The webmaster wanted to give a special shout-out to Mr. Saito, whom he has relied on for many years...)

(´-`).。oO(Over 30 years of use and the total cost was just around 4,000 yen... it is hard to find anything else with such incredible value...)

(´-`).。oO(Well then, please continue with the setup. Good luck with the environment configuration...)

Command Not Found

If the terminal shows python3: command not found, the PATH may not be configured correctly. Follow the steps below to check and set it up.

1. Locate the command

Check where the python3 command is installed.

which python3

If it is not found, check the common installation paths.

ls /usr/local/bin/python3
ls /opt/homebrew/bin/python3

On macOS, use python3 instead of python. macOS may have an old Python 2 registered as python, but Python 2 has already reached end of life.

2. Check your shell

echo $SHELL

If the output is /bin/zsh, edit ~/.zshrc. If it is /bin/bash, edit ~/.bashrc.

3. Add the path to PATH

Once you know the installation path, add it to your shell configuration file.

For macOS (zsh):

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

For Linux (bash):

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

On Windows, the easiest fix is to reinstall Python and check "Add python.exe to PATH". To add it manually, go to "System Properties" → "Environment Variables" → "Path" and add the Python installation folder.

Uninstalling Python

To uninstall the Python version installed via Homebrew, run the following command.

brew uninstall python

If you find any errors or copyright issues, please .