# setting up pyradiomics in python3 virtual env't

**URL:** <https://discourse.slicer.org/t/setting-up-pyradiomics-in-python3-virtual-envt/43434>\
**Category:** Radiomics\
**Created:** [June 20, 2025, 2:47pm UTC](https://discourse.slicer.org/t/setting-up-pyradiomics-in-python3-virtual-envt/43434 "2025-06-20T14:47:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tsc/32/80474_2.png) [@tsc](https://discourse.slicer.org/u/tsc)\
**Post date:** [June 20, 2025, 2:47pm UTC](https://discourse.slicer.org/t/setting-up-pyradiomics-in-python3-virtual-envt/43434/1 "2025-06-20T14:47:41Z")

</div>

I am having some trouble with pyradiomics in my python3 virtual env’t on one particular server. The issue may be that numpy 1.21.5 is present on the server and numpy 2.2.6 is present in the virtual env’t. Pyradiomics and all dependencies are setup in the virtual env’t.

pip3 list from inside the virtual env’t shows the following:

> (mcs-virtual) tomcat@server03:/home/tomcat-tmp/mcs-virtual$ pip3 list  
> Package Version
> 
> * * *
> 
> colorama 0.4.6  
> contourpy 1.3.2  
> cycler 0.12.1  
> docopt 0.6.2  
> fonttools 4.58.2  
> imageio 2.37.0  
> kiwisolver 1.4.8  
> lazy\_loader 0.4  
> matplotlib 3.10.3  
> networkx 3.4.2  
> numpy 2.2.6  
> opencv-python 4.11.0.86  
> packaging 25.0  
> pillow 11.2.1  
> pip 22.0.2  
> pydicom 3.0.1  
> pykwalify 1.8.0  
> pyparsing 3.2.3  
> pyradiomics 3.0.1  
> python-dateutil 2.9.0.post0  
> PyWavelets 1.8.0  
> ruamel.yaml 0.18.14  
> ruamel.yaml.clib 0.2.12  
> scikit-image 0.25.2  
> scipy 1.15.3  
> setuptools 80.9.0  
> simpleitk 2.5.0  
> six 1.17.0  
> tifffile 2025.5.10

Python in the virtual env’t:

> (mcs-virtual) tomcat@server03:/home/tomcat-tmp/mcs-virtual/$ which python  
> /home/tomcat-tmp/mcs-virtual/bin/python

radiomics is present under the site-packages folder in the virtual env:

> (mcs-virtual) tomcat@server03:/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages/radiomics$ ls  
> base.py featureextractor.py glcm.py glszm.py ngtdm.py scripts \_version.py  
> \_cmatrices.cpython-310-x86\_64-linux-gnu.so firstorder.py gldm.py imageoperations.py **pycache** shape2D.py  
> \_cshape.cpython-310-x86\_64-linux-gnu.so generalinfo.py glrlm.py **init**.py schemas shape.py

When I try to import radiomics, I see the following:

> (mcs-virtual) tomcat@server03:/home/tomcat-tmp/mcs-virtual/$ python
> 
> > > > import radiomics
> 
> A module that was compiled using NumPy 1.x cannot be run in  
> NumPy 2.2.6 as it may crash. To support both 1.x and 2.x  
> versions of NumPy, modules must be compiled with NumPy 2.0.  
> Some module may need to rebuild instead e.g. with ‘pybind11\>=2.12’.
> 
> If you are a user of the module, the easiest solution will be to  
> downgrade to ‘numpy\<2’ or try to upgrade the affected module.  
> We expect that some modules will need time to support NumPy 2.
> 
> Traceback (most recent call last): File “”, line 1, in   
> File “/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages/radiomics/ **init**.py”, line 286, in   
> from radiomics import \_cmatrices as cMatrices # noqa: F401  
> AttributeError: \_ARRAY\_API not found  
> Error loading C extensions  
> Traceback (most recent call last):  
> File “/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages/radiomics/ **init**.py”, line 286, in   
> from radiomics import \_cmatrices as cMatrices # noqa: F401  
> ImportError: numpy.core.multiarray failed to import  
> Traceback (most recent call last):  
> File “”, line 1, in   
> File “/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages/radiomics/ **init**.py”, line 297, in   
> raise e  
> File “/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages/radiomics/ **init**.py”, line 286, in   
> from radiomics import \_cmatrices as cMatrices # noqa: F401  
> ImportError: numpy.core.multiarray failed to import

This is the path from inside the virtual env’t

> (mcs-virtual) tomcat@server03:/home/tomcat-tmp/mcs-virtual$ python
> 
> > > > import sys  
> > > > print(sys.path)  
> > > > [‘’, ‘/usr/lib/python310.zip’, ‘/usr/lib/python3.10’, ‘/usr/lib/python3.10/lib-dynload’, ‘/home/tomcat-tmp/mcs-virtual/lib/python3.10/site-packages’]

Numpy 1 is present on the server, but Numpy 2 is inside the virtual env’t. Ideally, I do not want to downgrade from Numpy 2 in my virtual env’t. This is a shared server and I do not want to upgrade from Numpy 1 on that server. Given that I’m inside a python virtual env’t, I thought that it be an isolated env’t. Any suggestions are appreciated.

Thanks!
