Skip to content

How to create and run executable of a monai code? #4197

Answered by VenturaFranklin
Bhagii2508 asked this question in Q&A
Discussion options

You must be logged in to vote

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.
And of course you need to replace the path sections…

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@Bhagii2508
Comment options

Comment options

You must be logged in to vote
1 reply
@KumoLiu
Comment options

Comment options

You must be logged in to vote
1 reply
@wyli
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@AmirV97
Comment options

@VenturaFranklin
Comment options

@AmirV97
Comment options

Answer selected by wyli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants