Problem with importing monai

Mohammad_Farhadirad: <p>hello everybody<br>
I’m trying to use monai but when I import it this error shows up.<br>
“The kernel appears to have died. It will restart automatically.”</p>
<p>I have installed it using pip install monai. and I’m using python 3.9.12.</p>
<p>when I use jupyter notebook extension in VS code this error shows up.<br>
“Canceled future for execute_request message before replies were done<br>
The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href="https://aka.ms/vscodeJupyterKernelCrash" rel="noopener nofollow ugc">here</a> for more info. View Jupyter log for further details.”</p>
<p>this happens even when I just write “import monai”</p>

ptrblck: <p>Try to run the <code>import monai</code> code snippet in a terminal and check if a better error message would be raised. Also, please create a GitHub issue with instructions how to reproduce it in the <a href="https://github.com/Project-MONAI/MONAI">MONAI repository</a> so the developers can take a look at it.</p>

Mohammad_Farhadirad: <p>Hi ptrblck thank for your answare.<br>
I did it and this error showed up.<br>
“&gt;&gt;&gt; import monai<br>
OMP: Error <span class="hashtag">#15:</span> Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.<br>
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see <a href="http://www.intel.com/software/products/support/." class="inline-onebox" rel="noopener nofollow ugc">Intel® Product Support</a>”</p>
<p>I used this code and it almost fixed.<br>
(import os<br>
os.environ[‘KMP_DUPLICATE_LIB_OK’]=‘True’<br>
import monai</p>
<p>'Failed to load image Python extension: [WinError 127] The specified procedure could not be found ’ )</p>
<p>I say almost fixed because although monai is imported, a message shows up, 'Failed to load image Python… ’<br>
Furthermore, the last line of the previous error says" that may cause crashes or silently produce incorrect results. "</p>

ptrblck: <aside class="quote no-group" data-username="Mohammad_Farhadirad" data-post="3" data-topic="161617">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mohammad_farhadirad/48/45298_2.png" class="avatar"> Mohammad_Farhadirad:</div>
<blockquote>
<p>I say almost fixed because although monai is imported, a message shows up, 'Failed to load image Python… ’</p>
</blockquote>
</aside>
<p>This warning is raised by <code>torchvision.io</code> and you should be able to ignore it unless you need to use the serialization support from this namespace.</p>
<aside class="quote no-group" data-username="Mohammad_Farhadirad" data-post="3" data-topic="161617">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/mohammad_farhadirad/48/45298_2.png" class="avatar"> Mohammad_Farhadirad:</div>
<blockquote>
<p>Furthermore, the last line of the previous error says" that may cause crashes or silently produce incorrect results. "</p>
</blockquote>
</aside>
<p>I agree that this sounds quite dangerous so I would probably try to properly fix your setup.</p>