How to create and run executable of a monai code? #4197
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
What doesn't work? What error? |
Beta Was this translation helpful? Give feedback.
-
Hi -I have the same problem. My program runs fine when executing from source but throws an error when I am running the executable created with pyinstaller: ImportError: cannot import name 'CacheDataset' from partially initialized module 'monai.data' (most likely due to a circular import) (.\monai\data_init_.pyc) Does anyone know how to resolve it? My executable was running fine before adding the monai/pytorch feature. |
Beta Was this translation helpful? Give feedback.
-
Hi thank you for the suggestion, but it seems the errors are specific to
monai. It tried adding the modules that have issues to hidden imports but
that does not help.
…On Fri, 16 Jun 2023, 03:30 YunLiu, ***@***.***> wrote:
Hi @plaresmedima <https://github.com/plaresmedima>, maybe you can try
some solutions introduced in
https://stackoverflow.com/questions/69739699/pyinstaller-importerror-cannot-import-name-ccompiler-from-partially-initiali
.
Hope it can help you, thanks!
—
Reply to this email directly, view it on GitHub
<#4197 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABOFKAYYOILFEDNS64TCJT3XLPAKRANCNFSM5UTJ6FIQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Dear Wenqi - just a quick note to say thank for your kind offer to look
into this. I have not had the time to write up a small example for you
unfortunately but I am keeping this on my todo list as it remains an
unsolved issue for us.
Prof. Steven Sourbron, PhD
Chair in Medical Imaging Physics
University of Sheffield, UK
*https
<https://www.sheffield.ac.uk/medicine/people/iicd/steven-sourbron>://www.sheffield.ac.uk/medicine/people/iicd/steven-sourbron
<https://www.sheffield.ac.uk/medicine/people/iicd/steven-sourbron>*
*Sheffield abdominal imaging research page*
<https://www.sheffield.ac.uk/medicine/research/research-themes/medical-imaging/medical-imaging-research/abdominal-imaging>
*Open source initiative in perfusion imaging* <http://www.osipi.org>
*Magnetic resonance imaging biomarkers for chronic kidney disease
<https://renalmri.org/>*
…On Fri, 16 Jun 2023 at 11:39, Wenqi Li ***@***.***> wrote:
Thanks for raising the issue, could you help create a small example to
demonstrate the issue? I can look into it. (Also a potential reason is that
this line of load modules is not involved
https://github.com/Project-MONAI/MONAI/blob/a89a0af10e70256fbe8641e71385ad2c2b3fb405/monai/__init__.py#L58
)
—
Reply to this email directly, view it on GitHub
<#4197 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABOFKA6RCLD7IX5LHDV5JPLXLQZVNANCNFSM5UTJ6FIQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I was able to get around this issue with the following code: import monai
datas = [(str(Path(monai.__file__).parent), "monai"),]
datas += PyInstaller.utils.hooks.collect_data_files("monai")
a = Analysis(
["{PATH_TO_YOUR_MAIN_FILE}"],
pathex=["{PATH_TO_YOUR_MAIN_DIR}"],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=None,
noarchive=False,
) Then you have your exe and collect configurations. There might be better ways to do this, but this worked for me.
@plaresmedima Please, when asking for help, include your code even when it's not a small example. Copy and paste whatever you have and that is a million times better than nothing. And a small example is 1000 times better, but any code is better than nothing. I hope this helps, good luck! |
Beta Was this translation helpful? Give feedback.
I was able to get around this issue with the following code:
Then you have your exe and collect configurations.
There might be better ways to do this, but this worked for me.
And of course you need to replace the path sections…