Skip to content

Python Setup 101 - Install & Use Virtual Environments

· 6 min

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:


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:


Why Should You Learn It?#

Even just a few basic command line skills can help you:


A Few Tips for Terminal Beginners:#

  1. Copy-paste is your friend – Don’t worry about remembering everything.
  2. Read carefully – Most terminal messages actually tell you what’s wrong (or not).
  3. Not all output is bad – Seeing text doesn’t mean something broke!
  4. 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:

Terminal window
python3 --version

But here’s the catch:

You should not use the system Python for your own projects.

Why?

Instead, we recommend:

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:

🖥️ On macOS:#

Open Terminal and run:

Terminal window
/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:

Terminal window
brew --version

🐧 On Linux:#

Terminal window
/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:#

Terminal window
brew install python@3.10

After installation, link it (macOS only):

Terminal window
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?

Terminal window
python3 -m venv myenv

This creates a folder myenv that contains an isolated Python environment.


Step 4: Activate the Environment#

🖥️ macOS / Linux:#

Terminal window
source myenv/bin/activate

🪟 Windows:#

Terminal window
myenv\Scripts\activate

You’ll see your prompt change to:

(myenv) $

You are now inside the virtual environment!


Step 5: Install Packages Inside venv#

Terminal window
pip install numpy pandas

❌ Deactivate When Done#

Terminal window
deactivate

Summary#

PlatformInstall PythonVirtual Env Commands
macOS/Linuxbrew install python@3.10python3 -m venv myenv + source ...
WindowsPython.org Installerpython -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:

  1. Log in with an admin user
  2. Promote your current user to administrator
  3. Then run the install script again:
Terminal window
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Error 2: Homebrew Installed, but brew Command Not Found#

Terminal window
brew --version
zsh: 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:

Terminal window
echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Then check again:

Terminal window
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#

Terminal window
(myenv) $ pip install sequenzo
ERROR: 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:

  1. First, install Python 3.10 or 3.11 using Homebrew:
Terminal window
brew install python@3.10
  1. Then create a virtual environment using that version:
Terminal window
/opt/homebrew/opt/python@3.10/bin/python3.10 -m venv myenv
  1. Activate the environment:
Terminal window
source myenv/bin/activate
  1. Confirm the version:
Terminal window
python --version
# Should show Python 3.10.x
  1. Now install sequenzo:
Terminal window
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:

Terminal window
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:

You can always confirm your Python version and pip location with:

Terminal window
which python
which pip

They should point to paths like:

/Users/[your-username]/myenv/bin/python
/Users/[your-username]/myenv/bin/pip