Quick solutions for common errors when setting up and running Face-Recon.
- ModuleNotFoundError: No module named 'src'
- ModuleNotFoundError: No module named 'cv2'
- dlib Installation Fails
- No space left on device (Windows)
- Other Common Issues
Traceback (most recent call last):
File "D:\Downloads\Face-Recon-1.2\Face-Recon-1.2\src\main_build_database.py", line 7, in <module>
from src.config import KNOWN_FACES_DIR, ENCODINGS_PATH
ModuleNotFoundError: No module named 'src'
This has been fixed in the latest version! Update your repository:
git pull origin mainIf you're still experiencing this issue, you can:
Option 1: Run as a module (Recommended)
# From the project root directory
python -m src.main_build_database
python -m src.main_realtime_recognitionOption 2: Add PYTHONPATH
# Linux/macOS
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
python src/main_build_database.py
# Windows (PowerShell)
$env:PYTHONPATH = "$env:PYTHONPATH;$(pwd)"
python src/main_build_database.py
# Windows (CMD)
set PYTHONPATH=%PYTHONPATH%;%cd%
python src\main_build_database.py(venv) D:\Downloads\Face-Recon-1.2\Face-Recon-1.2>python src/main_realtime_recognition.py
Traceback (most recent call last):
File "D:\Downloads\Face-Recon-1.2\Face-Recon-1.2\src\main_realtime_recognition.py", line 5, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
OpenCV is not installed. Install it with:
pip install opencv-pythonIf that fails, try:
Option 1: Use conda
conda install -c conda-forge opencvOption 2: Install headless version (for servers)
pip install opencv-python-headlessOption 3: Install from system packages (Linux)
# Ubuntu/Debian
sudo apt-get install python3-opencv
# Then in your virtual environment
pip install opencv-pythonBuilding wheel for dlib (pyproject.toml) ... error
ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects
The face_recognition library depends on dlib, which needs to be compiled from source. This often fails because:
- Missing C++ compiler
- Missing CMake
- Insufficient disk space
- Python version too new (e.g., Python 3.13)
Python 3.13 is too new. Downgrade to Python 3.11:
# Using pyenv (Linux/macOS)
pyenv install 3.11.8
pyenv local 3.11.8
# Or download from python.org and reinstall# 1. Download the appropriate wheel from:
# https://github.com/jloh02/dlib/releases
# 2. Install the downloaded wheel
# For Python 3.11 64-bit Windows:
pip install dlib-19.24.1-cp311-cp311-win_amd64.whl
# 3. Then install face_recognition
pip install face_recognition# Create new conda environment
conda create -n face-recon python=3.11
conda activate face-recon
# Install dlib from conda-forge
conda install -c conda-forge dlib opencv
# Install remaining dependencies
pip install face_recognition Flask imutilsIf you want to compile from source:
-
Install Microsoft C++ Build Tools
- Select "Desktop development with C++"
- Install the package (requires ~6 GB)
-
Install CMake
- Add to PATH during installation
-
Restart your terminal and try again:
pip install dlib
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y build-essential cmake
# Install dlib
pip install dlibIf all else fails, use Docker:
# See INSTALL.md for Docker installation instructions
docker build -t face-recon .
docker run -it face-reconC:\Users\jonov\AppData\Local\Temp\pip-install-sr1owdu6\dlib_c433f59f3207469cb703894d4b49b662\build\temp.win-amd64-cpython-313\Release\_dlib_pybind11.dir\Release\image4.obj': No space left on device
dlib compilation requires 5-10 GB of temporary disk space, typically on the C: drive.
-
Clean up C: drive:
- Delete temporary files
- Empty Recycle Bin
- Run Disk Cleanup
- Uninstall unused programs
-
Ensure at least 10 GB free on C:
# In Command Prompt (run as Administrator)
# Change to a drive with more space
set TMP=D:\Temp
set TEMP=D:\Temp
# Create the directory if it doesn't exist
mkdir D:\Temp
# Now try installing
pip install dlibOr make it permanent:
- Open "Environment Variables" (Windows Settings → System → About → Advanced system settings)
- Set
TMPandTEMPto a location with more space (e.g.,D:\Temp) - Restart your terminal
Avoid compilation entirely by using pre-built wheels:
# Download from: https://github.com/jloh02/dlib/releases
pip install dlib-19.24.1-cp311-cp311-win_amd64.whl
pip install face_recognitionConda packages are pre-compiled:
conda install -c conda-forge dlib
pip install face_recognitionProblem: Many packages don't have pre-built wheels for Python 3.13 yet.
Solution: Use Python 3.10 or 3.11:
# Check your Python version
python --version
# If it's 3.13, install Python 3.11 insteadError: IOError: Webcam not accessible
Solutions:
- Check if another application is using the webcam
- Grant camera permissions (Windows Settings → Privacy → Camera)
- Try a different camera index:
# Edit src/main_realtime_recognition.py video_capture = cv2.VideoCapture(1) # Try 1, 2, etc.
Error: PermissionError: [Errno 13] Permission denied
Solutions:
# Run without sudo, use virtual environment instead
python -m venv venv
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windows
pip install -r requirements.txtProblem: Missing Visual C++ Redistributable
Solution:
- Download and install Visual C++ Redistributable
- Restart your computer
- Try again
If you're still experiencing issues:
-
Check the full installation guide: INSTALL.md
-
Search existing issues: GitHub Issues
-
Create a new issue with:
- Your operating system and version
- Python version:
python --version - Full error message (copy-paste the entire traceback)
- What you've already tried
-
Quick diagnostic:
# Run this and share the output python --version pip --version pip list python -c "import sys; print(f'Platform: {sys.platform}')"
# Check versions
python --version
pip --version
# Update pip
pip install --upgrade pip
# Install dependencies
pip install -r requirements.txt
# Install individual packages
pip install opencv-python numpy Flask
# Check installed packages
pip list
# Test imports
python -c "import cv2; print('OpenCV OK')"
python -c "import face_recognition; print('face_recognition OK')"
python -c "from src.config import BASE_DIR; print('Project OK')"
# Run the application
python src/main_build_database.py
python src/main_realtime_recognition.py
# Or as modules
python -m src.main_build_database
python -m src.main_realtime_recognition