AIM-Harvard / pyradiomics

Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks. Support: https://discourse.slicer.org/c/community/radiomics
http://pyradiomics.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.18k stars 497 forks source link

Error loading C extensions, switching to python calculation #340

Closed ghzhao1992 closed 6 years ago

ghzhao1992 commented 6 years ago

image hello sir/lady: I installed the basic package already, but when I run the cell ,it is ...

JoostJM commented 6 years ago

It appears to be unable to load the C-compiled extension. Does the file _cmatrices.pyd exist in the folder E:\annaconda\lib\site-packages\radiomics\__init__.py? Did you have any issues during setup of PyRadiomics?

ghzhao1992 commented 6 years ago

image

firstly, cd pyradiomics then, python -m pip install -r requirements.txt finally, python setup.py install The installation was successful and finally a file was generated which named 'pyradiomics-0+unknown-py3.5-win-amd64.egg'.It has a folder 'radiomics', and in 'radiomics' ,I find the' init.py' and '_cmatrices.pyd'

JoostJM commented 6 years ago

@ghzhao1992, strange. 1) pyradiomics was unable to determine it's version during install. Did you clone the git repository or downloaded the zip file? When pyradiomics is installed from the git repository, the setup script is able to determine the exact version of pyradiomics. This version is also included in the output of calculated features, enabling you to reproduce your extraction, even years from now. 2) the output in your first message shows it's trying to load radiomics from a folder radiomics which is contained in the root site-packages folder, not in pyradiomics-0+unknown-py3.5-win-amd64.egg.

ad 2) what a possible cause is this: if you installed pyradiomics from a wheel before, it will create the radiomics folder directly in the site-packages folder, if you install from source, it will be installed in the .egg folder. Then, during an attempted import the wheel-installed version is found first, causing it to attempt to load that version of pyradiomics.

To check/fix this do the following: First, delete the radiomics folder contained in the site-packages folder. Second, check if the easy-install.pth file (which should be present in your site-packages folder) contains the .egg folder. If you open the file (using a text editor), check if there is a line like ./pyradiomics-0+unknown-py3.5-win-amd64.egg. If not add this. Then try to load import radiomics in a python interactor (ensure that this is in a new cmd line window, so that the PATH variables are reset.

ghzhao1992 commented 6 years ago

Thank you for your detailed answers. the problem is solved! As you said, I have a copy of pyradiomics here,named 'pyradiomics-0+unknown-py3.5-win-amd64.egg'. it's not the file that generated correctly by the zip file. Thank you again!

JoostJM commented 6 years ago

If you downloaded the source code from the github as a zip-file and then installed from that zip-file, the version will not be set correctly. This is due to the fact that when building from source, the code expects that source to be a git-repository and extract the version from there. However, the zip-file is not a repository and therefore, does not have the part that will yield the version.

Using git clone will download the entire repository and fix this error.