Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monailabel cann't run correctly in windows 11 #1794

Open
Xu-Charles opened this issue Dec 10, 2024 Discussed in #1793 · 5 comments
Open

Monailabel cann't run correctly in windows 11 #1794

Xu-Charles opened this issue Dec 10, 2024 Discussed in #1793 · 5 comments

Comments

@Xu-Charles
Copy link

Discussed in #1793

Originally posted by Xu-Charles December 10, 2024
I have python 3.9.20 environment with PyTorch and CUDA installed.
cuda version :12.4

(monailabel) C:\Users\Administrator>python
Python 3.9.20 (main, Oct 3 2024, 07:38:01) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import torch
print(torch.cuda.is_available())
True

But, I get the following error when running monailabel:

(monailabel) C:\Users\Administrator>monailabel
Using PYTHONPATH=C:\ProgramData\Anaconda3\envs;
""
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\monailabel\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\site-packages\monailabel\main.py", line 24, in
from monailabel.config import settings

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\site-packages\monailabel\config.py", line 23, in
class Settings(BaseSettings):

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\site-packages\monailabel\config.py", line 109, in Settings
if is_package_installed("SAM-2")

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\site-packages\monailabel\config.py", line 20, in is_package_installed
return name in sorted(x.name for x in distributions())

File "C:\ProgramData\Anaconda3\envs\monailabel\lib\site-packages\monailabel\config.py", line 20, in
return name in sorted(x.name for x in distributions())

AttributeError: 'PathDistribution' object has no attribute 'name'

@lassoan
Copy link
Collaborator

lassoan commented Dec 10, 2024

The issue is not that you use Windows11 but that you use Python-3.9.

I have run into the same issue. The problem was easy to fix (just use get method and tweak the sorting), but then when I noticed that there were further issues (SAM is not supported on Python 3.9) then I just gave up.

The error happens when you import MONAILabel, so it seems MONAILabel is not tested at all with Python-3.9 (or the failure is ignored), so I'm not sure if MONAILabel is supported on Python-3.9.

@SachidanandAlle
Copy link
Collaborator

SachidanandAlle commented Dec 10, 2024

Try: pip install importlib_metadata==8.4.0
if works, then please share the existing package version details for the above.

@SachidanandAlle
Copy link
Collaborator

is all good?

@lassoan
Copy link
Collaborator

lassoan commented Dec 16, 2024

If it helps at all, for me, with Python-3.9 MONAILabel failed on this line:

return name in sorted(x.name for x in distributions())

I've tried installing various importlib_metadata versions but in the end I've fixed the issue by changing the code to this:

return name in (x.metadata.get('Name') for x in distributions())

(It seems that I removed the sorting, I don't know why, maybe that was causing some issue, too, and you probably don't really need the sorting anyway)

Since then I decided to switch to Python-3.10, so I did not investigate Python-3.9 any further.

@SachidanandAlle
Copy link
Collaborator

#1800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants