This guide provides detailed troubleshooting for Windows users installing hazelbean, with a focus on resolving Cython compilation issues.
- Quick Diagnosis
- Common Issues
- Solution 1: Conda Compiler Tools (Recommended)
- Solution 2: Visual Studio Build Tools
- Verification
- Troubleshooting Specific Errors
If you're seeing errors like:
ImportError: cannot import name 'cython_functions' from 'hazelbean.calculation_core'error: Microsoft Visual C++ 14.0 or greater is requiredUnable to find vcvarsall.bat
The issue: Your system lacks the C/C++ compiler tools needed to build Cython extensions.
Quick test:
conda activate hazelbean_env
python scripts/verify_installation.pyThis will diagnose the exact issue and provide targeted solutions.
Symptoms:
ImportError: cannot import name 'cython_functions' from 'hazelbean.calculation_core'Cause: Cython extensions weren't compiled during installation.
Solution: See Solution 1 or Solution 2 below.
Symptoms:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools"
Cause: Windows doesn't have a C++ compiler installed by default.
Solution: Choose either the conda-based compiler (easier) or Visual Studio Build Tools (more robust).
Symptoms:
pip install -e .completes without errors- But
import hazelbeanstill fails with ImportError
Cause: May be using wrong Python environment or files weren't installed correctly.
Solution:
# Verify you're in the correct environment
conda activate hazelbean_env
which python # Should show path containing 'hazelbean_env'
# Force reinstall
pip install -e . --no-deps --force-reinstallThis is the easiest solution and doesn't require large downloads.
# Activate your hazelbean environment
conda activate hazelbean_env
# Install the Windows compiler toolchain via conda
conda install -c conda-forge m2w64-toolchain libpythonWhat this installs:
m2w64-toolchain: MinGW-w64 based compiler tools (GCC for Windows)libpython: Python development headers needed for extension building
# Now install hazelbean (this will compile Cython extensions)
pip install -e . --no-deps --force-reinstallExpected output: You should see compilation messages like:
Building extension for hazelbean.calculation_core.cython_functions
...
Successfully installed hazelbean
python scripts/verify_installation.pyShould show:
✅ Hazelbean imported successfully
✅ Cython extensions compiled and loaded
✅ ProjectFlow initialization works
If you see "command 'gcc' failed":
# Try reinstalling the toolchain
conda remove m2w64-toolchain libpython
conda install -c conda-forge m2w64-toolchain libpython
# Clear any cached builds
pip cache purge
pip install -e . --no-deps --force-reinstallThis is the "official" Microsoft solution and more robust, but requires a larger download (~3-7 GB).
- Go to: https://visualstudio.microsoft.com/downloads/
- Scroll down to "All Downloads"
- Expand "Tools for Visual Studio"
- Download "Build Tools for Visual Studio 2022" (or latest version)
- Run the installer
- When prompted for workloads, select:
- ✅ "Desktop development with C++"
- On the right side panel, ensure these are checked:
- ✅ MSVC v143 - VS 2022 C++ x64/x86 build tools (or latest)
- ✅ Windows 10 SDK (or Windows 11 SDK)
- ✅ C++ CMake tools for Windows
- Click "Install" (will take 15-30 minutes)
Important: Close and reopen your terminal/command prompt after installation so the build tools are in your PATH.
# Activate environment
conda activate hazelbean_env
# Install hazelbean (will now use Visual Studio compiler)
pip install -e . --no-deps --force-reinstallpython scripts/verify_installation.pyIf Build Tools installed but still getting errors:
-
Verify installation:
# Check if cl.exe (MSVC compiler) is available where clIf not found, the build tools PATH may not be set correctly.
-
Use Developer Command Prompt:
- Search for "Developer Command Prompt for VS 2022" in Start Menu
- Run it
- Activate conda environment:
conda activate hazelbean_env - Try installation again:
pip install -e . --no-deps --force-reinstall
python -c "import hazelbean as hb; from hazelbean.calculation_core import cython_functions; print('✅ Success!')"python scripts/verify_installation.pyThis checks:
- Python version compatibility
- Hazelbean import
- Cython extensions
- Key dependencies
- Basic functionality
import hazelbean as hb
import tempfile
# Test ProjectFlow
with tempfile.TemporaryDirectory() as tmp:
p = hb.ProjectFlow(tmp)
print("✅ ProjectFlow works")
# Test Cython functions
from hazelbean.calculation_core import cython_functions
print("✅ Cython extensions loaded")Full error:
error: Unable to find vcvarsall.bat
Solution: Install Visual Studio Build Tools (Solution 2) or use conda compiler tools (Solution 1).
Full error:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
Solution: Install libpython:
conda install -c conda-forge libpythonSymptoms:
pip install -e .completes without errors- Import still gives
ImportError
Diagnosis:
# Check if .pyd files were created
cd hazelbean/calculation_core
dir *.pydSolutions:
-
If no .pyd files found:
# Try python setup.py directly python setup.py build_ext --inplace -
If .pyd files exist but import fails:
# Check for DLL dependencies python -c "from hazelbean.calculation_core import cython_functions"
If you see "DLL load failed", install Visual C++ Redistributables:
When running tests:
python -m pytest hazelbean_tests/system/test_smoke.py -vIf you see:
ImportError while loading conftest: cannot import name 'cython_functions'
Solution: The Cython extensions aren't compiled. Follow Solution 1 or 2 above.
If you're using conda (recommended), always:
- Activate the conda environment first:
conda activate hazelbean_env - Use
pip installwithin the conda environment - Never use
pip install --userin conda environments
Hazelbean requires 64-bit Python. Verify:
import sys
print(f"Python is {sys.maxsize > 2**32 and '64-bit' or '32-bit'}")If 32-bit, reinstall with 64-bit Python.
Hazelbean requires Python 3.10+. Check:
python --versionIf older, create new environment:
mamba create -n hazelbean_env python=3.11
conda activate hazelbean_env
mamba env update -f environment.ymlIf none of these solutions work:
-
Collect diagnostic information:
python scripts/verify_installation.py > diagnosis.txt python --version >> diagnosis.txt conda list >> diagnosis.txt
-
Check existing issues: https://github.com/jandrewjohnson/hazelbean_dev/issues
-
Open a new issue with:
- Your
diagnosis.txtoutput - Error messages (full traceback)
- Windows version
- What you've tried
- Your
- Cython Compilation on Windows: https://github.com/cython/cython/wiki/CythonExtensionsOnWindows
- Visual Studio Build Tools: https://visualstudio.microsoft.com/downloads/
- Conda Compiler Tools: https://anaconda.org/conda-forge/m2w64-toolchain
- Main Documentation: Getting Started Guide