# Build Slicer with the system Python

**URL:** <https://discourse.slicer.org/t/build-slicer-with-the-system-python/41633>\
**Category:** Support\
**Created:** [February 11, 2025, 3:58pm UTC](https://discourse.slicer.org/t/build-slicer-with-the-system-python/41633 "2025-02-11T15:58:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin-g](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/martin-g/32/79430_2.png) [@martin-g](https://discourse.slicer.org/u/martin-g)\
**Post date:** [February 11, 2025, 3:58pm UTC](https://discourse.slicer.org/t/build-slicer-with-the-system-python/41633/1 "2025-02-11T15:58:39Z")

</div>

Hi,

I am trying to build Slicer and I want to use as many `-DSlicer_USE_SYSTEM_***=1` as possible.  
I provide all the dependencies with conda.

My conda environment is activated and there I have Python 3.13.1 installed, together with `packaging` and many more packages.

I use the following command to generate the build files:

```auto
cmake -S . -B build \
    -DCMAKE_C_COMPILER=$CC \
    -DCMAKE_CXX_COMPILER=$CXX \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS $LDFLAGS" \
    -DCMAKE_C_FLAGS="$CFLAGS $LDFLAGS" \
    -DSlicer_FORCED_REVISION="12345678" \
    -Wno-dev \
    -DSlicer_USE_SYSTEM_LZMA=1 \
    -DSlicer_USE_SYSTEM_zlib=1 \
    -DSlicer_USE_SYSTEM_bzip2=1 \
    -DSlicer_USE_SYSTEM_curl=1 \
    -DSlicer_USE_SYSTEM_LibFFI=1 \
    -DSlicer_USE_SYSTEM_DCMTK=1 \
    -DSlicer_USE_SYSTEM_OpenSSL=1 \
    -DSlicer_USE_SYSTEM_LibArchive=1 \
    -DSlicer_USE_SYSTEM_Swig=1 \
    -DSlicer_USE_SimpleITK_SHARED="ON" \
    -DSlicer_VTK_SMP_IMPLEMENTATION_TYPE="TBB" \
    -DBUILD_TESTING="OFF" \
    -DCMAKE_MESSAGE_LOG_LEVEL=ERROR \
    -DSlicer_USE_SYSTEM_python=1 \
    -DPYTHON_EXECUTABLE:FILEPATH="/home/mgrigorov/git/slicer/.pixi/envs/default/bin/python3" \
    -DSlicer_USE_SYSTEM_python-pythonqt-requirements=1

```

But it fails with:

```auto
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'packaging'
CMake Error at CMake/ExternalProjectDependencyForPython.cmake:111 (message):
  Could not import module for required dependency 'packaging' using
  '/usr/bin/python3.9' interpreter.
Call Stack (most recent call first):
  SuperBuild/External_python-pythonqt-requirements.cmake:24 (ExternalProject_FindPythonPackage)
  CMake/ExternalProjectDependency.cmake:890 (include)
  CMake/ExternalProjectDependency.cmake:964 (ExternalProject_Include_Dependencies)
  SuperBuild.cmake:473 (ExternalProject_Include_Dependencies)
  CMakeLists.txt:779 (include)

-- Configuring incomplete, errors occurred!

```

It seems it ignores the PYTHON\_EXECUTABLE setting…  
`/home/mgrigorov/git/slicer/.pixi/envs/default/bin/` is the first entry in $PATH, so both `python` and `python3` are used from there.

Any idea why cmake tries to use `/usr/bin/python3.9` instead ?

P.S. If I try to use the vendored Python, i.e. `-DSlicer_USE_SYSTEM_python=0` then it installs SlicerPython that is for x86\_64 while I run it on Linux aarch64 system.
