{"record":{"id":"7df9c730722ae745","repo":"PaddlePaddle/PaddleOCR","slug":"cannot-compile-pse-if-your-system-is-windows","errorCode":null,"errorMessage":"Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+","messagePattern":"Cannot compile pse: (.+?), if your system is windows, you need to install all the default components of `desktop development using C\\+\\+` in visual studio 2019\\+","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"ppocr/postprocess/pse_postprocess/pse/__init__.py","lineNumber":26,"sourceCode":"#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport sys\nimport os\nimport subprocess\n\npython_path = sys.executable\n\nori_path = os.getcwd()\nos.chdir(\"ppocr/postprocess/pse_postprocess/pse\")\nif (\n    subprocess.call(\"{} setup.py build_ext --inplace\".format(python_path), shell=True)\n    != 0\n):\n    raise RuntimeError(\n        \"Cannot compile pse: {}, if your system is windows, you need to install all the default components of `desktop development using C++` in visual studio 2019+\".format(\n            os.path.dirname(os.path.realpath(__file__))\n        )\n    )\nos.chdir(ori_path)\n\nfrom .pse import pse\n","sourceCodeStart":8,"sourceCodeEnd":34,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/ppocr/postprocess/pse_postprocess/pse/__init__.py#L8-L34","documentation":"RuntimeError raised at import time of ppocr.postprocess.pse_postprocess.pse when the package fails to compile its Cython/C++ extension in-place by shelling out to 'setup.py build_ext --inplace'. It means no working C/C++ toolchain (or broken environment) was available to build the PSE postprocessing module, which is required for PSE/ PSENet text detection.","triggerScenarios":"Importing anything that pulls in pse_postprocess (i.e. running PSE detection training/inference) on a machine without a C++ compiler, without the Python dev headers, or on Windows without the 'Desktop development with C++' workload of Visual Studio 2019+.","commonSituations":"Fresh Windows machines with only VS BuildTools partial workloads; slim Docker images (python:slim) missing gcc; Cython not installed so setup.py fails; stale build artifacts from a different Python version.","solutions":["On Windows, install Visual Studio 2019+ with ALL default components of the 'Desktop development with C++' workload, then retry.","On Linux/macOS ensure a compiler and Python headers exist (apt install build-essential python3-dev) and that Cython is installed (pip install cython).","Build manually to see the real error: cd ppocr/postprocess/pse_postprocess/pse && python setup.py build_ext --inplace.","Delete stale .so/.pyd artifacts and rebuild if you switched Python versions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import shutil, subprocess, sys\n\ndef can_compile_pse() -> bool:\n    compiler = shutil.which('cl') or shutil.which('gcc') or shutil.which('clang')\n    if not compiler:\n        return False\n    r = subprocess.run([sys.executable, 'setup.py', 'build_ext', '--inplace'],\n                       cwd='ppocr/postprocess/pse_postprocess/pse', capture_output=True)\n    return r.returncode == 0","typeGuard":null,"tryCatchPattern":"try:\n    from ppocr.postprocess.pse_postprocess.pse import pse\nexcept (RuntimeError, ImportError) as e:\n    raise SystemExit(\n        'PSE postprocess requires a C++ toolchain. '\n        'Windows: install VS 2019+ with the \"Desktop development with C++\" workload. '\n        'Linux: apt install build-essential python3-dev && pip install cython.'\n    ) from e","preventionTips":["Provision build tools in the image/environment before running PSE models (build-essential + python3-dev + cython, or the full VS C++ workload).","Bake the compiled pse extension into Docker images at build time so runtime imports never compile.","Avoid PSE configs on machines without compilers; use DB configs instead."],"tags":["postprocess","build","compiler","windows","environment"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}