Geant4Py install error

I’m trying to install python modules, but I get this error while configuring:

$ cd /home/user/geant4/geant4.10.06.p03/environments/g4py
$ export GEANT4_INSTALL=/home/user/geant4/geant4.10.06.p03-install/
$ mkdir build && cd build
$ cmake ..

CMake Error at G4PythonHelpers.cmake:15 (file):
file RELATIVE_PATH must be passed a full path to the file:
Call Stack (most recent call first):
CMakeLists.txt:14 (include)

CMake Error at CMakeLists.txt:23 (geant4_add_feature):
Unknown CMake command “geant4_add_feature”.

I follow this steps to install Geant4:

$ mkdir geant4 && cd geant4
$ wget -nc
$ tar -xvf geant4.10.06.p03.tar.gz
$ cd ..
$ mkdir geant4.10.06.p03-build && cd geant4.10.06.p03-build
$ make -j4
$ make install

Thanks in advance for your help!

There’s no longer a need to build Geant4Py separately, the install you made with:

$ make -j4
$ make install

should have built and installed the modules under /home/user/geant4/geant4.10.06.p03-install/lib64/python3.X/site-packages. The lib64 might be lib depending on your exact platform, and X be be for the minor version of python on your system, but the modules should be present!

1 Like

Thank you for your reply.

As you mentioned, the module Geant4 is present in “/home/user/geant4/geant4.10.06.p03-install/lib/python3.8/site-packages/Geant4”
If I understood correctly, I don’t need to compile g4py again in a build directory like in older versions. But how can I compile and install g4py modules such as NISTmaterials, MedicalBeam …

These modules are now only built as part of the testing procedure. Adding first class examples for Geant4Py as for the C++ libraries is on the todo lost, but other requirements, features and testing for 10.7 is taking all the time at the moment.

Also, a higher priority item for Geant4Py maintenance and support will be migration to pybind11 (which will also significantly change both these tests and the new examples).

1 Like


With the new version (10.07) I still cannot compile any Geant4Py example due to the g4py modules which are not available, is there a solution to fix this problem ?


Maybe it is in the g4py/tests/g4pytest.

I wanted to bring this topic up again. I was able to install most of Geant4Py correctly, but not all of it. For example, using the answer given here, I am missing the following gdml package. Everything else appears to have installed correctly.

I wanted to answer my own question. I found in CMakeLists.txt that


so I recompiled with cmake -DGEANT4_USE_GDML=ON and it appears to have worked.

@bmorgan have you had an issue with gdml in geant4py? I am now getting the error:

Traceback (most recent call last):                                                                                        
File "<string>", line 1, in <module>                                                                                    
File "/home/glicka/anaconda3/lib/python3.8/site-packages/Geant4/", line 32, in <module> 
from .G4gdml import *                                                                                               
ImportError: /home/glicka/anaconda3/lib/python3.8/site-packages/Geant4/ undefined symbol: _ZN12G4GDMLParser13ImportRegionsEv                                                                       

which I get when I add

from .G4gdml import *

to the file.

EDIT: I reinstalled everything from scratch and the import error went away. I still had to add the import statement though.