Python / 6 MIN READ
Python Installing
Installing Python and setting up your environment
From the original Fervor library. Examples may use older package versions.
How to Install Python: A Friendly Step-by-Step Guide
So you want to dive into the world of Python? Excellent choice! It’s like having a Swiss Army knife for coding—simple, versatile, and powerful. Let’s get Python set up on your computer so you can start automating tasks, building cool projects, or just impressing your friends.
Step 1: Check if Python is Already Installed
Why?
Many systems come with Python pre-installed, especially macOS and Linux.
How?
- Open a terminal:
- Windows: Open the Command Prompt by typing
cmdin the search bar. - macOS/Linux: Use Spotlight (
Cmd + Space) or your terminal app.
- Windows: Open the Command Prompt by typing
- Type:
or:python --versionpython3 --version
What Happens?
- If you see something like
Python 3.x.x, congrats—you already have it! - If you see an error or a version less than 3.7, you’ll need to install or update Python.
Step 2: Download Python
Where?
Head over to python.org.
- Click the Downloads tab (the website usually highlights the best version for your system).
- Download the installer for your operating system:
- Windows:
Windows Installer - macOS:
macOS Installer - Linux: You may need to use your package manager (more on that below).
- Windows:
Step 3: Install Python
For Windows Users
- Open the downloaded
.exefile. - Before you click Install Now, check the box that says:
(This is super important—it makes Python accessible from the command line.)Add Python 3.x to PATH - Click Install Now.
- Wait for the installation to finish, and click Close.
For macOS Users
- Open the downloaded
.pkgfile. - Follow the on-screen instructions.
- After installation, verify it:
- Open Terminal and type:
python3 --version
- Open Terminal and type:
For Linux Users
- Open your terminal.
- Use your package manager to install Python:
- Debian/Ubuntu:
sudo apt update sudo apt install python3 - Fedora:
sudo dnf install python3
- Debian/Ubuntu:
- Verify installation:
python3 --version
Step 4: Install a Text Editor or IDE
You’ll need a place to write your Python code. Here are some popular choices:
- VS Code (Recommended)
- Download: code.visualstudio.com
- Extensions to install: Python, Pylance.
- PyCharm (Feature-rich but heavier)
- Download: jetbrains.com/pycharm.
- IDLE (Comes with Python, lightweight).
Step 5: Test Your Installation
Why?
Make sure everything’s working before diving into coding.
How?
- Open your terminal or command prompt.
- Type:
or:python3python - You should see something like:
Python 3.x.x (some build info) Type "help", "copyright", "credits" or "license" for more information. >>> - Type your first Python command:
print("Hello, Python!") - If it prints
Hello, Python!, you’re good to go. 🎉
Step 6: Install Pip (Optional)
What is Pip?
It’s Python’s package manager, like an app store for libraries and tools.
How?
- Pip often comes pre-installed with Python 3. Ensure it’s there:
pip --version - If it’s missing, you can install it:
python3 -m ensurepip --upgrade
You’re All Set!
You now have Python installed and ready to use. Whether you’re writing a script, automating tasks, or building the next big thing, Python is ready to be your trusty companion.
Next Steps:
- Learn the basics: variables, loops, functions.
- Try small projects, like a calculator or a guessing game.
- Explore libraries like
requests(for web stuff) andpandas(for data).
Happy coding, and remember: The only bugs you want are the ones you debug. 🐛
Bonus Trouble Shooting on Mac
Tutorial: Fixing “command not found” for Python on Mac (Using python3)
So, you’re on a Mac and running into the dreaded "command not found" issue when you try to run python. Don’t worry; Macs sometimes like to play hard to get with Python. Here’s how you can fix it step by step, including installing Python 3 using Homebrew.
Step 1: Check for Python 3 Installation
Before jumping into installation, let’s check if Python 3 is already on your Mac. Open your Terminal (press Cmd + Space, type Terminal, and hit Enter) and run:
python3 --version
What Happens:
- If you see something like
Python 3.x.x: 🎉 Python 3 is installed! Skip to Step 5. - If you see
command not found: No worries, let’s install Python 3.
Step 2: Install Homebrew (If Not Already Installed)
Homebrew is like a magical package manager for macOS. If you don’t already have it installed:
- Open your Terminal.
- Run this command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Follow the on-screen instructions. Homebrew may ask for your password—type it in and hit Enter (it won’t show as you type, but that’s normal).
Verify Homebrew Installation:
Once the installation is complete, verify it with:
brew --version
You should see a version number like Homebrew 4.x.x.
Step 3: Install Python 3 Using Homebrew
Now that Homebrew is ready, install Python 3 with:
brew install python3
What Happens:
- Homebrew downloads and installs the latest version of Python 3.
- It also sets up
pip3(Python’s package manager) for you.
Step 4: Verify Python 3 Installation
After installation, check if Python 3 is correctly installed:
python3 --version
You should see something like Python 3.x.x. If so, Python 3 is good to go! 🎉
Step 5: Running Python Scripts
Let’s say you have a script called clean_vt.py that you want to run. Use python3 to execute it:
- Navigate to the folder where your script is stored. For example:
cd path/to/your/script - Run the script:
python3 clean_vt.py
If your script runs without errors, you’re all set!
Step 6: (Optional) Create an Alias for Easier Use
Tired of typing python3 all the time? You can create an alias to make life easier.
- Open your Terminal and edit your shell configuration file:
- For zsh (default on newer Macs):
nano ~/.zshrc - For bash (older Macs):
nano ~/.bash_profile
- For zsh (default on newer Macs):
- Add this line at the bottom of the file:
alias python="python3" - Save and exit (press
Ctrl+O, thenEnter, thenCtrl+X). - Apply the changes:
or:source ~/.zshrcsource ~/.bash_profile
Now you can simply type python to run Python 3!
Step 7: Install Additional Tools (Optional)
Pip (Python Package Manager)
pip usually comes with Python 3, but if you want to ensure it’s up to date:
python3 -m ensurepip --upgrade
Install popular libraries like requests or numpy:
pip3 install requests numpy
Troubleshooting
-
Command Not Found After Installation:
Make sure Homebrew’s binaries are in your PATH. Add this to your~/.zshrcor~/.bash_profile:export PATH="/usr/local/bin:/usr/local/sbin:$PATH"Then run:
source ~/.zshrc -
Still Having Issues?
Let me know what you’re seeing, and I’ll help you debug!
Now you’re all set to conquer Python on your Mac! 🎉 Time to put that clean_vt.py script to work or start building your next big project. 🚀