Before starting the build process, ensure your system meets these requirements:
- Ubuntu 22.04 LTS (fresh installation recommended)
- At least 8GB of free disk space
- Internet connection for downloading packages
- Sudo privileges
pythonOCC 8.0.1.1 requires the following components:
| Component | Version | Purpose |
|---|---|---|
| Python | ≥ 3.10 | Runtime environment |
| NumPy | ≥ 1.17 | Arrays of the Geom, Poly, TColStd, TColgp... modules |
| OpenCascade | 8.0.1 | Core CAD functionality |
| SWIG | 4.2.1 to 4.5.1 | Interface generation |
| CMake | ≥ 3.18 | Build system |
First, update your system and install required packages:
sudo apt-get update
sudo apt-get install -y \
wget \
libglu1-mesa-dev \
libgl1-mesa-dev \
libxmu-dev \
libxi-dev \
build-essential \
cmake \
libfreetype6-dev \
tk-dev \
python3-dev \
rapidjson-dev \
python3 \
git \
python3-pip \
libpcre2-devSWIG 4.2.1 or higher is required but not available in Ubuntu's default repositories. Build it from source:
wget http://prdownloads.sourceforge.net/swig/swig-4.5.1.tar.gz
tar -zxvf swig-4.5.1.tar.gz
cd swig-4.5.1
./configure
make -j$(nproc)
sudo make installDownload and extract OpenCascade 8.0.1:
wget https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V8_0_1.tar.gz
tar -xvzf V8_0_1.tar.gz
cd OCCT-8_0_1
mkdir cmake-build
cd cmake-buildConfigure and build OpenCascade:
cmake -DINSTALL_DIR=/opt/occt801 \
-DBUILD_RELEASE_DISABLE_EXCEPTIONS=OFF \
..
make -j$(nproc)
sudo make installAdd OpenCascade libraries to the system:
sudo bash -c 'echo "/opt/occt801/lib" >> /etc/ld.so.conf.d/occt.conf'
sudo ldconfigClone and build pythonOCC:
git clone https://github.com/tpaviot/pythonocc-core.git
cd pythonocc-core
mkdir cmake-build && cd cmake-build
# Set installation directory (optional)
PYTHONOCC_INSTALL_DIRECTORY=${PYTHONOCC_INSTALL_DIRECTORY:-/usr/local}
cmake \
-DOCCT_INCLUDE_DIR=/opt/occt801/include/opencascade \
-DOCCT_LIBRARY_DIR=/opt/occt801/lib \
-DCMAKE_BUILD_TYPE=Release \
-DPYTHONOCC_INSTALL_DIRECTORY=$PYTHONOCC_INSTALL_DIRECTORY \
..
make -j$(nproc) && sudo make installAdd OpenCascade libraries to your environment:
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/occt801/lib' >> ~/.bashrc
source ~/.bashrcNote: if you're running a conda environment on a recent linux distribution, you migh have to
conda update -c conda-forge libstdcxx-ng libgcc-ngBefore starting the build process, ensure your system meets these requirements:
- Windows 10 or 11 (64-bit)
- At least 10GB of free disk space
- Internet connection for downloading packages
- Administrator privileges
| Component | Version | Download Link |
|---|---|---|
| Visual Studio | 2019 or 2022 Community | Download |
| Python | ≥ 3.10 | Download |
| NumPy | ≥ 1.17 | pip install numpy |
| CMake | ≥ 3.18 | Download |
| Git | Latest | Download |
| RapidJSON | Latest | Download |
| SWIG | 4.2.1 to 4.5.1 | Download |
| OpenCascade | 8.0.1 | Download |
-
Install Visual Studio 2019/2022 Community Edition:
- During installation, select "Desktop development with C++"
- Include "Windows 10 SDK" and "MSBuild"
-
Install Python 3.10 or later:
- Download and run the installer
- Check "Add Python to PATH"
- Choose "Customize installation"
- Select "pip" and "py launcher"
- Install for all users
-
Install CMake:
- Download and run the installer
- Add CMake to the system PATH for all users
-
Install Git:
- Download and run the installer
- Use Git from Windows Command Prompt
- Use OpenSSL library
-
Install SWIG:
- Download SWIG 4.5.1 for Windows
- Extract to C:\swigwin
- Add C:\swigwin to the system PATH
-
Install RapidJSON
- Clone the git repository git clone https://github.com/Tencent/rapidjson.git
Binaries for dependencies can be downloaded at https://dev.opencascade.org/resources/download/3rd-party-components
- Download OpenCascade 8.0.1 for Windows
- Extract to, for example, occt-8.0.1
If the binaries are not available, consider compiling by yourself OCCT on Windows. Refer to the official OpenCascade Technology documentation https://dev.opencascade.org/doc/overview/html/build_upgrade.html
When installing OpenCascade and third-party libraries, you should have a structure similar to the one described at https://dev.opencascade.org/doc/overview/html/index.html#intro_install_windows
C:\OpenCASCADE-8.0.1-vc10-64 ├── ffmpeg-3.3.4-gpl-64 ├── freeimage-3.17.0-vc10-64 ├── freetype-2.6.3-vc10-64 ├── occt-8.0.1 ├── qt486-vc10-64 ├── tclkit-86-64 ├── vtk-6.1.0-vc10-64 └── zlib-1.2.8-vc10-64
- Clone the repository:
git clone https://github.com/tpaviot/pythonocc-core.git
cd pythonocc-core- Create build directory:
mkdir cmake-build
cd cmake-build- Configure with CMake:
cmake -G "Visual Studio 17 2022" -A x64 ^
-DCMAKE_BUILD_TYPE=Release ^
-DOCCT_INCLUDE_DIR=C:\OpenCASCADE-8.0.1-vc10-64\occt-8.0.1\inc ^
-DOCCT_LIBRARY_DIR=C:\OpenCASCADE-8.0.1-vc10-64\occt-8.0.1\win64\vc14\lib ^
-DOCCT_ESSENTIALS_ROOT=C:\OpenCASCADE-8.0.1-vc10-64
..If using CMake GUI, make sure to set these two variables before clicking the "Generate" button:
OCCT_INCLUDE_DIR=C:\OpenCASCADE-8.0.1-vc10-64\occt-8.0.1\inc
OCCT_LIBRARY_DIR=C:\OpenCASCADE-8.0.1-vc10-64\occt-8.0.1\win64\vc14\lib
- Build:
cmake --build . --config Release- Install:
cmake --install .NumPy is required to build pythonOCC (see the system requirements). To also enable fast STL file loading with the NumPy arrays of the MeshDS module, add the following CMake flag during pythonOCC configuration:
-DPYTHONOCC_MESHDS_NUMPY=ONInstall additional Python packages for full functionality:
pip install svgwrite numpy numpy-stl matplotlib PyQt5Verify the installation:
python3
>>> from OCC.Core.gp import gp_Pnt
>>> p = gp_Pnt(1., 2., 3.)
>>> p.X()
1.0Run the complete test suite:
pip install pytest
pytestTry the demo applications:
git clone https://github.com/tpaviot/pythonocc-demos
cd pythonocc-demos
python3 examples/core_classic_occ_bottle.py-
Library not found errors:
sudo ldconfig
-
SWIG version mismatch:
- Ensure no other SWIG versions are installed
- Verify installation:
swig -version
-
DLL not found errors:
- Verify PATH environment variable includes OpenCascade bin directory
- Check Visual Studio installation
- if you encounter the following error:
-
DLL not found for 3rd part libraries:
If it was not done at build time, you can define the OCCT_ESSENTIALS_ROOT path at run time, by setting the env var:
setx OCCT_ESSENTIALS_ROOT "%CASROOT%\win64\vc14\bin"- CMake configuration errors:
- Ensure all paths use backslashes
- Verify Visual Studio installation
- Check environment variables
For more examples and documentation, visit: