If you’ve ever struggled with Python version conflicts, broken packages, or system Python messing up your workflow — you’re not alone. The good news is: with the right setup, you can avoid all that.
This guide will walk you through a reliable way to:
- Install Python 3.10 (without affecting your system Python)
- Create isolated project environments using venv
- Work consistently across macOS, Linux, and Windows
Don’t Fear the Terminal — You’re in Control!#
If you’re completely new to programming or Python, you might feel a little intimidated when you see a black-and-white screen with blinking text — the command line (also called terminal, shell, or console).
Don’t worry. You’re not alone — many beginners feel that way. But here’s the good news:
⚠️ Warnings are okay.
❌ Errors are what you need to pay attention to.
💡 Curiosity is your biggest tool — not perfection.
What Is the Command Line?#
The command line is a way to tell your computer what to do using text commands, instead of clicking buttons like you would in a normal app (like Chrome or Microsoft Word).
The interface you’re used to — with buttons, windows, and icons — is called a GUI (Graphical User Interface).
But programmers often prefer the CLI (Command Line Interface) because it’s:
- Faster (you can do more with fewer steps)
- More powerful (you can automate things)
- Scriptable (you can reuse and share your setup)
Why Should You Learn It?#
Even just a few basic command line skills can help you:
- Install and manage Python efficiently
- Create isolated environments for clean, conflict-free development
- Run, test, and debug your code like a pro
A Few Tips for Terminal Beginners:#
- Copy-paste is your friend – Don’t worry about remembering everything.
- Read carefully – Most terminal messages actually tell you what’s wrong (or not).
- Not all output is bad – Seeing text doesn’t mean something broke!
- You can’t break your computer – Almost everything you do here is safe if you’re following trusted steps.
Now, let’s get started with setting up Python and your virtual environment.
Wait — Doesn’t My Computer Already Have Python?#
Yes! Most macOS and Linux systems come with a built-in version of Python. This is called the system Python, and it’s used by your operating system to run essential tools and scripts.
You can check it by running:
python3 --version
But here’s the catch:
You should not use the system Python for your own projects.
Why?
- It’s managed by the OS — you’re not supposed to upgrade or remove it
- It might be an outdated version (e.g. Python 2.7 or 3.8)
- Installing packages globally can break system-level tools
Instead, we recommend:
- Installing your own version of Python (e.g. 3.10) alongside the system one
- Using virtual environments to isolate dependencies per project
That’s what this guide will help you do — cleanly and safely.
Step 1: Install Homebrew (macOS & Linux only)#
Windows users: You can skip this step and go directly to Step 2. Windows has a different way of managing software, and for installing Python, the official installer is the most straightforward path.
Homebrew is a package manager designed for macOS (and later adapted for Linux). It helps users easily install and manage software from the command line — something that’s built-in and commonly used on Unix-like systems.
On Windows, however:
-
You can simply download and install Python using the official installer from python.org, which already includes everything you need (like pip and venv).
-
You don’t need a separate package manager like Homebrew to get started.
-
Tools such as Chocolatey or Scoop exist on Windows, but they’re optional and more suited for power users or automation scripts.
🖥️ On macOS:#
Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After installation, add it to your shell config (Terminal will prompt you).
Then run:
brew --version
🐧 On Linux:#
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
After it’s done, follow the printed instructions to add Homebrew to your PATH
.
Step 2: Install Python 3.10 (or 3.9/3.11)#
macOS/Linux users can use
brew
, Windows users use the official installer.
🍏 macOS / Linux:#
brew install python@3.10
After installation, link it (macOS only):
brew link python@3.10 --force
🪟 Windows:#
Go to the official Python website
Download the Windows installer and check:
✅ “Add Python to PATH” before installing.
Step 3: Create a Virtual Environment (venv
)#
Once Python 3.10+ is installed, it’s a good practice to create a virtual environment for your project.
A virtual environment is an isolated Python environment — it keeps your project’s dependencies separate from other projects and your system Python, preventing version conflicts and messy setups.
If you’d like a deeper explanation with examples, check out my full tutorial here: 👉 What Is a Python Virtual Environment, and Why Should You Use It?
python3 -m venv myenv
This creates a folder myenv
that contains an isolated Python environment.
Step 4: Activate the Environment#
🖥️ macOS / Linux:#
source myenv/bin/activate
🪟 Windows:#
myenv\Scripts\activate
You’ll see your prompt change to:
(myenv) $
You are now inside the virtual environment!
Step 5: Install Packages Inside venv
#
pip install numpy pandas
❌ Deactivate When Done#
deactivate
Summary#
Platform | Install Python | Virtual Env Commands |
---|---|---|
macOS/Linux | brew install python@3.10 | python3 -m venv myenv + source ... |
Windows | Python.org Installer | python -m venv myenv + myenv\Scripts\activate |
当然可以!以下是扩写后的 “Common Errors & Fixes” 教程段落,对每个错误都进行了清晰的解释、保留了关键错误信息,并对隐私信息(如用户名)做了适当模糊处理。你可以直接插入到你的文档中。
If You Encounter Errors: Common Issues & How to Fix Them#
Setting up Python and your development environment can sometimes lead to confusing errors — especially on macOS. Here are a few common issues and how to fix them.
Error 1: Can’t Run the Homebrew Install Script (No sudo
Access)#
==> Checking for `sudo` access (which may request your password)...Sorry, user [your-username] may not run sudo on [your-device-name].Need sudo access on macOS (e.g. the user [your-username] needs to be an Administrator)!
Cause:
You’re trying to install Homebrew using a user account that does not have administrator privileges.
Solution:
Go to System Settings → Users & Groups, and make sure your account is checked as “Allow this user to administer this computer.”
If that option is greyed out or locked:
- Log in with an admin user
- Promote your current user to administrator
- Then run the install script again:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Error 2: Homebrew Installed, but brew
Command Not Found#
brew --versionzsh: command not found: brew
You see this after installing Homebrew, and the terminal suggests:
Run these commands in your terminal to add Homebrew to your PATH: echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/[your-username]/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
Cause:
Homebrew is installed, but the system doesn’t know where to find it because it hasn’t been added to your shell’s PATH
.
Solution:
Copy and paste the following into your terminal:
echo >> ~/.zprofileecho 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofileeval "$(/opt/homebrew/bin/brew shellenv)"
Then check again:
brew --version
You should now see something like Homebrew 4.x.x
.
Error 3: You’ve Activated a Virtual Environment, but pip install
Still Fails#
(myenv) $ pip install sequenzoERROR: Ignored the following versions that require a different python version: 0.1.0 Requires-Python <3.12,>=3.9 ...ERROR: Could not find a version that satisfies the requirement sequenzo
Cause:
You’re using Python 3.12, but the sequenzo
package currently only supports Python 3.9 to 3.11.
Solution:
- First, install Python 3.10 or 3.11 using Homebrew:
brew install python@3.10
- Then create a virtual environment using that version:
/opt/homebrew/opt/python@3.10/bin/python3.10 -m venv myenv
- Activate the environment:
source myenv/bin/activate
- Confirm the version:
python --version# Should show Python 3.10.x
- Now install
sequenzo
:
pip install sequenzo
Extra Tip: Upgrade pip
When You See This#
If you see:
[notice] A new release of pip is available: 24.3.1 -> 25.0.1
Just upgrade it:
pip install --upgrade pip
Keeping pip up to date ensures compatibility with newer packages and fixes bugs.
Still stuck?#
If you’re still hitting errors, try checking:
- Are you using the correct Python version?
- Is the virtual environment activated?
- Did you install Homebrew properly and add it to your
PATH
?
You can always confirm your Python version and pip location with:
which pythonwhich pip
They should point to paths like:
/Users/[your-username]/myenv/bin/python/Users/[your-username]/myenv/bin/pip