Starting a computer vision course is exciting, but the first real win usually comes before any model training or image processing trick. It comes from having a setup that works. This guide to python cv course week 1 setup python opencv and project structure walks through the practical steps to build a stable local environment so you can focus on learning instead of debugging avoidable installation issues.
If you are a beginner, week 1 is where good habits start. If you are already somewhat comfortable with Python, this is the right time to clean up your workflow and use a project structure that will still make sense by week 8 or week 12. We will cover Python installation, terminal checks, virtual environments, OpenCV installation, optional starter packages, folder organization, a first sanity-check script, and common fixes for the errors that almost everyone hits at least once.
Why week 1 setup matters for computer vision projects
Computer vision projects depend on a few moving parts working together: your Python interpreter, installed packages, editor configuration, image files, and consistent file paths. When one part is out of sync, the result is often a confusing error such as:
pipinstalls a package, but your script cannot import itcv2fails even though OpenCV appears to be installed- an image loads as
Nonebecause the path is wrong - scripts, notebooks, screenshots, and outputs get mixed in one folder
That is why python cv course week 1 setup python opencv and project structure is more than a checklist. It is the foundation for the rest of the course. A clean setup helps you:
- avoid version conflicts
- keep course experiments isolated from other Python work
- debug faster because your files are organized
- share or revisit projects later without confusion
- move from simple image operations to larger OpenCV projects with less friction
What to install before coding
Before you write any OpenCV code, make sure the core tools are installed and visible from your terminal.
1. Python
For most beginner computer vision workflows, a recent stable version of Python 3 is the right choice. In many cases, Python 3.10, 3.11, or 3.12 will work well with current package versions. If your course explicitly recommends a version, follow that first.
Check Python from the terminal:
python --version
On some systems, especially macOS and Linux, you may need:
python3 --version
If this command fails, Python may not be installed correctly or may not be added to your system path.
2. pip
pip is Python’s package installer. You will use it to install OpenCV and related libraries.
Check pip:
pip --version
Or:
pip3 --version
A safer, often more consistent option is to call pip through Python itself:
python -m pip --version
This reduces the chance of installing packages into the wrong interpreter.
3. A code editor
You do not need anything fancy, but you do need an editor that lets you open folders, edit Python files, and run code comfortably. Visual Studio Code is a common choice because it has good Python support and makes interpreter selection easier. PyCharm is also a solid option, especially if you prefer a full Python-focused IDE.
Whichever editor you choose, make sure you know how to:
- open the project folder
- view the integrated terminal
- select the Python interpreter for your virtual environment
- run a script from the correct folder
4. Terminal access
Much of setup is easier to verify from the terminal than from the editor. You should be comfortable opening a terminal and running commands in your course project directory.
Python CV course week 1 setup Python OpenCV and project structure for beginners
If you are new to local development, the most important beginner habit is this: use one dedicated folder for the course and one virtual environment per project or course workspace. That single habit prevents many import and dependency problems later.
A practical setup flow looks like this:
- Install Python
- Confirm Python and pip from the terminal
- Create a course folder
- Create and activate a virtual environment inside that folder
- Install OpenCV and a few supporting libraries
- Build a simple folder structure for scripts, images, notebooks, and outputs
- Run one sanity-check script before moving on
Beginners often skip step 7 and start coding immediately. That is a mistake. A sanity-check script tells you whether your setup is actually working before the course material gets more complex.
Create an isolated environment for the course
Virtual environments keep package installations separate from your system Python and from other projects. This is especially helpful in computer vision, where package versions matter and you may later add tools such as Jupyter, image libraries, or model-related dependencies.
Why isolation helps
- prevents package conflicts between projects
- makes debugging easier because dependencies are local and explicit
- supports reproducibility with a
requirements.txtfile - helps your editor use the correct interpreter
Create a project folder
mkdir python-cv-course cd python-cv-course
Create a virtual environment
Windows:
python -m venv .venv
macOS/Linux:
python3 -m venv .venv
Activate the environment
Windows Command Prompt:
.venv\Scripts\activate
Windows PowerShell:
.venv\Scripts\Activate.ps1
macOS/Linux:
source .venv/bin/activate
After activation, your terminal usually shows the environment name, often something like (.venv) at the start of the prompt.
Upgrade pip inside the environment
python -m pip install --upgrade pip
This is a small step, but it helps reduce install issues with newer packages.
Install OpenCV the right way
For a typical beginner setup, install the standard wheel package:
pip install opencv-python
This package provides the cv2 module used in most beginner computer vision lessons.
Should you install opencv-contrib-python instead?
Usually, no. Beginners should start with opencv-python unless the course specifically requires modules from the contrib package. The contrib package includes additional modules, but it also adds complexity you may not need in week 1.
If you do need the extra modules later, read the course requirement carefully before switching. In many setups, you should not install both packages at the same time because that can create confusion.
Confirm cv2 imports correctly
After installation, test it directly from Python:
python -c "import cv2; print(cv2.__version__)"
If that prints a version number, your OpenCV installation is working in the currently active environment.
Optional but useful starter packages
OpenCV is enough to start, but a few extra packages are useful in a course environment.
pip install numpy matplotlib jupyter
NumPy
NumPy is essential because OpenCV images are represented as arrays. Even if you do not use NumPy directly in week 1, it quickly becomes part of normal image manipulation work.
Matplotlib
Matplotlib is useful for displaying images in notebooks and comparing outputs. It is especially helpful when you want inline plots instead of OpenCV display windows.
Jupyter
Jupyter is optional. Use it if your course includes exploration, annotations, or side-by-side visual explanation. For beginners, scripts are often better for learning clean structure, while notebooks are good for experiments and demonstrations.
A balanced approach is:
- use scripts for reusable course exercises
- use notebooks for exploration and notes
Build a practical project structure
A good folder structure keeps raw data separate from code and outputs. It also helps you avoid hard-to-read projects full of random file names.
Here is a clean beginner-friendly structure:
python-cv-course/ ├── .venv/ ├── images/ │ ├── input/ │ └── output/ ├── notebooks/ ├── src/ │ ├── __init__.py │ └── week01_sanity_check.py ├── tests/ ├── requirements.txt └── README.md
What each folder is for
src/— Python scripts for the courseimages/input/— original images you read into your programsimages/output/— processed images generated by your scriptsnotebooks/— Jupyter notebooks for experimentstests/— small tests if you later validate functionsrequirements.txt— dependency list for recreating the environmentREADME.md— short notes about setup and usage
If your course grows into multiple weekly units, you can also organize scripts by week:
src/ ├── week01/ ├── week02/ └── week03/
That can be cleaner than putting every file directly in one folder.
Comparison table: common setup choices
| Decision | Recommended for beginners | Alternative | Practical note |
|---|---|---|---|
| Environment management | venv |
Conda | venv is built into Python and simple for week 1 |
| OpenCV package | opencv-python |
opencv-contrib-python |
Use contrib only if your course needs extra modules |
| Coding format | Python scripts in src/ |
Jupyter notebooks only | Scripts are easier to organize and rerun consistently |
| Image storage | images/input and images/output |
All files in project root | Separate inputs and outputs to avoid clutter |
| Install command style | python -m pip install ... |
pip install ... |
Calling pip through Python helps avoid interpreter mismatch |
Write the first sanity-check script
Now create a file named src/week01_sanity_check.py and add a simple script that verifies the core pieces of your setup.
from pathlib import Path import cv2 print("OpenCV version:", cv2.__version__) project_root = Path(__file__).resolve().parents[1] input_path = project_root / "images" / "input" / "sample.jpg" output_path = project_root / "images" / "output" / "sample_gray.jpg" image = cv2.imread(str(input_path)) if image is None: raise FileNotFoundError(f"Could not read image: {input_path}") gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) output_path.parent.mkdir(parents=True, exist_ok=True) cv2.imwrite(str(output_path), gray) print("Input image:", input_path) print("Output image saved to:", output_path)
Add a test image named sample.jpg to images/input/, then run:
python src/week01_sanity_check.py
If everything is working, you should see:
- the OpenCV version printed
- no import errors
- a processed grayscale image saved into
images/output/
This script also demonstrates a useful habit: using pathlib and relative project paths instead of fragile absolute file paths.
Common setup problems and fixes
pip not found
If pip is not recognized, try:
python -m pip --version
If that works, keep using python -m pip for installs. If it does not, your Python installation may be incomplete or not added to your system path.
Interpreter mismatch
This is one of the most common issues. You install OpenCV, but your editor or terminal runs a different Python interpreter.
Check which Python is active:
python -c "import sys; print(sys.executable)"
Run the same check in your editor terminal and compare. If the paths differ, select the correct interpreter in your editor, ideally the one inside .venv.
cv2 import errors
If you get ModuleNotFoundError: No module named 'cv2', the package is likely installed somewhere other than the interpreter you are running. With your virtual environment activated, reinstall:
python -m pip install opencv-python
Then verify:
python -c "import cv2; print(cv2.__version__)"
Image path mistakes
If cv2.imread() returns None, OpenCV usually did not find the file. Common reasons:
- the file name is wrong
- the extension is wrong, such as
.pngvs.jpg - the script is being run from a different working directory
- you used a relative path that depends on the current terminal location
Using pathlib based on the script location is safer than guessing where the terminal is.
Virtual environment activation problems on PowerShell
Some Windows systems block script execution by default. If activation fails in PowerShell, you can either use Command Prompt or review your execution policy settings. Many beginners simply switch to Command Prompt for week 1 and revisit PowerShell later.
Recommended naming and workflow conventions
Week 1 is the right time to adopt conventions that keep your course projects readable.
Use descriptive file names
week01_sanity_check.pyweek02_image_resize.pyweek03_color_spaces.py
Avoid names like test.py, new.py, or final_final.py.
Prefer relative paths
Do not hard-code file paths tied to one machine. Build paths relative to your project root so the code works on different systems.
Keep outputs separate from inputs
Never overwrite your original images unless the lesson explicitly asks for it. Save outputs to a dedicated folder.
Track dependencies
Once your base environment is ready, create a dependency file:
pip freeze > requirements.txt
This is useful if you need to recreate the environment later.
Keep scripts small early on
In the first weeks, simple single-purpose scripts are easier to debug than one large file doing many unrelated tasks.
Pros and cons of this setup approach
Pros
- simple and beginner-friendly
- uses standard Python tools available on most systems
- reduces package conflicts through isolation
- makes course files easier to navigate
- scales well as projects become more complex
Cons
- requires a little terminal familiarity
- beginners may find interpreter selection confusing at first
- Jupyter plus scripts can feel like two workflows if not organized well
- different operating systems use slightly different activation commands
Week 1 completion checklist
Before moving into image basics, confirm the following:
- Python is installed and the version prints correctly
pipworks from the terminal- your course folder exists and is dedicated to this work
- the virtual environment is created and activates correctly
- OpenCV installs inside the environment
import cv2works and prints a version number- optional starter packages like NumPy are installed if needed
- your folder structure includes
src,images/input,images/output, andnotebooksif you use them - your sanity-check script reads an image and writes an output file
requirements.txtis saved for later reuse
FAQ
How do I set up Python and OpenCV for week 1 of a computer vision course?
Install Python 3, verify it from the terminal, create a project folder, create and activate a virtual environment, then install OpenCV with python -m pip install opencv-python. Finally, test with python -c "import cv2; print(cv2.__version__)".
What is the best project structure for beginners learning Python and OpenCV?
A practical beginner structure includes src/ for scripts, images/input/ for raw images, images/output/ for processed results, notebooks/ for experiments, and a requirements.txt file for dependencies.
Should I use opencv-python or opencv-contrib-python for a beginner setup?
Start with opencv-python unless your course specifically requires contrib modules. It is the simpler option for week 1 and enough for basic image reading, writing, color conversion, resizing, and many introductory tasks.
Why is cv2 not importing after I install OpenCV with pip?
The most common cause is interpreter mismatch. You may have installed the package into one Python environment while your script is running with another. Activate the intended virtual environment and use python -m pip install opencv-python, then verify the active interpreter path.
Do I need a virtual environment for a Python computer vision course?
Strictly speaking, no, but in practice, yes, it is strongly recommended. A virtual environment keeps your course dependencies isolated, reduces conflicts, and makes it easier to reproduce your setup later.
What folders should I create for images, scripts, notebooks, and outputs in OpenCV projects?
A solid starting point is src/, images/input/, images/output/, and notebooks/. This keeps code, source files, and generated results clearly separated.
Conclusion
A reliable week 1 setup is not busywork. It is the starting point for every successful OpenCV exercise that comes next. If your Python interpreter is clear, your virtual environment is active, OpenCV imports correctly, and your project folders are organized from day one, the rest of the course becomes much easier to follow.
The goal of python cv course week 1 setup python opencv and project structure is simple: remove preventable friction. Once your environment, dependencies, and first sanity-check script are in place, you are ready to move on to image loading, display, color spaces, and the core building blocks of computer vision with confidence.
