Calling a Python function from Matlab having problem with NumPy

조회 수: 6 (최근 30일)
Santiago Marin
Santiago Marin 2019년 10월 29일
댓글: Paul Kuberry 2020년 3월 26일
Im trying to call a function from Python, using a library called PyRadiomics, the function works good when called from another Python script, but when used on Matlab throws me some errors related to NumPy, im using Python 3.7.
This is the Python code:
import numpy as np
def extractRadiom(Image,Mask):
from radiomics import featureextractor
settings = {'label': 255}
extractor = featureextractor.RadiomicsFeatureExtractor(additionalInfo=True, **settings)
result = extractor.execute(Image, Mask)
return result
Is a fairly simple code, that takes an image and its mask paths and make some calculations on them.
>>>py.RadiomicsFunc.extractRadiom(imagPath,maskPath)
Error using _distributor_init><module> (line 34)
Python Error: ImportError: DLL load failed: The specified module could not be found.
Error in __init__><module> (line 140)
from . import _distributor_init
Error in __init__><module> (line 12)
import numpy # noqa: F401
Error in RadiomicsFunc>extractRadiom (line 15)
The line 15 in the code is empty, and whatever I put there throws the error, I think is about the numpy importing, but why it works good when called from another Python script? Maybe it has something to do with the path Matlab takes to import numpy or something.
Edit: translated the error

채택된 답변

Santiago Marin
Santiago Marin 2019년 10월 29일
편집: Santiago Marin 2019년 10월 29일
After trying many things I started Matlab from my anaconda command window in the enviroment where I had the Python 3.7 with numpy and that solved the issue.
  댓글 수: 1
Paul Kuberry
Paul Kuberry 2020년 3월 26일
Another option ( the 2nd part of the accepted answer at https://www.mathworks.com/matlabcentral/answers/427187-problem-with-python-numpy?s_tid=mwa_osa_a ) solves the issue without requiring that you use the anaconda command window.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by