nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

importlib.metadata.PackageNotFoundError: nnunet

Open squaresoft2015 opened this issue 2 years ago • 7 comments

After I upgrade the python version from 3.6 to 3.8, the program continuously prompt: importlib.metadata.PackageNotFoundError: nnunet No matter what command I do. Any solutions?

squaresoft2015 avatar May 13 '22 08:05 squaresoft2015

You should give more details about what is actually happening before anyone can help you.

  • Full stack trace?
  • When does this happen? What are you running?
  • What did you already try to resolve the problem?

thijsgelton avatar May 13 '22 10:05 thijsgelton

The full stack trace is as follows: Traceback (most recent call last): File "/home/zhangge/.conda/envs/nnUNet/bin/nnUNet_convert_decathlon_task", line 33, in sys.exit(load_entry_point('nnunet', 'console_scripts', 'nnUNet_convert_decathlon_task')()) File "/home/zhangge/.conda/envs/nnUNet/bin/nnUNet_convert_decathlon_task", line 22, in importlib_load_entry_point for entry_point in distribution(dist_name).entry_points File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/importlib/metadata.py", line 503, in distribution return Distribution.from_name(distribution_name) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/importlib/metadata.py", line 177, in from_name raise PackageNotFoundError(name) importlib.metadata.PackageNotFoundError: nnunet

The error continously prompt for all the command. In the previous scetion, I ran: nnUNet_plan_and_preprocess -t 8

I have checked the .bashrc file and the path is all correct.

squaresoft2015 avatar May 14 '22 16:05 squaresoft2015

When switching python versions, did you redo this command: pip install -e . ?

thijsgelton avatar May 16 '22 11:05 thijsgelton

After I ran the command pip install -e . The prompt became a warning:

-bash: The: command not found (nnUNet) [zhangge@KYJS-node-B-1 nnUNet]$ If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/ -bash: If: command not found (nnUNet) [zhangge@KYJS-node-B-1 nnUNet]$ (nnUNet) [zhangge@KYJS-node-B-1 nnUNet]$ warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))

and an error message jumped after epoch 0: `epoch: 0 Traceback (most recent call last): File "/home/zhangge/.conda/envs/nnUNet/bin/nnUNet_train", line 33, in sys.exit(load_entry_point('nnunet', 'console_scripts', 'nnUNet_train')()) File "/home/zhangge/nnUNet/nnunet/run/run_training.py", line 179, in main trainer.run_training() File "/home/zhangge/nnUNet/nnunet/training/network_training/nnUNetTrainerV2.py", line 440, in run_training ret = super().run_training() File "/home/zhangge/nnUNet/nnunet/training/network_training/nnUNetTrainer.py", line 317, in run_training super(nnUNetTrainer, self).run_training() File "/home/zhangge/nnUNet/nnunet/training/network_training/network_trainer.py", line 456, in run_training l = self.run_iteration(self.tr_gen, True) File "/home/zhangge/nnUNet/nnunet/training/network_training/nnUNetTrainerV2.py", line 247, in run_iteration output = self.network(data) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/zhangge/nnUNet/nnunet/network_architecture/generic_UNet.py", line 391, in forward x = self.conv_blocks_contextd File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/zhangge/nnUNet/nnunet/network_architecture/generic_UNet.py", line 142, in forward return self.blocks(x) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/container.py", line 141, in forward input = module(input) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/zhangge/nnUNet/nnunet/network_architecture/generic_UNet.py", line 65, in forward x = self.conv(x) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, **kwargs) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 592, in forward return self._conv_forward(input, self.weight, self.bias) File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 587, in _conv_forward return F.conv3d( RuntimeError: CUDA error: no kernel image is available for execution on the device CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. Exception in thread Thread-5: Traceback (most recent call last): File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 932, in _bootstrap_inner Exception in thread Thread-4: Traceback (most recent call last): File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 932, in _bootstrap_inner self.run() self.run() File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 870, in run Fatal Python error: could not acquire lock for <_io.BufferedWriter name=''> at interpreter shutdown, possibly due to daemon threads Python runtime state: finalizing (tstate=0x55caf226f730)

Thread 0x00007f6095feb700 (most recent call first): File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 1202 in invoke_excepthook File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 934 in _bootstrap_inner File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 890 in _bootstrap

Thread 0x00007f60a5fff700 (most recent call first): File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 1202 in invoke_excepthook File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 934 in _bootstrap_inner File "/home/zhangge/.conda/envs/nnUNet/lib/python3.8/threading.py", line 890 in _bootstrap

Current thread 0x00007f61cd0a9740 (most recent call first): <no Python frame> Aborted`

squaresoft2015 avatar May 17 '22 01:05 squaresoft2015

Please check the installation instructions in the readme. They specify clearly that you need to have PyTorch properly installed first.

thijsgelton avatar May 17 '22 07:05 thijsgelton

I have install PyTorch with command "pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116" before applying installation of nnUNet. The error remains the same.

squaresoft2015 avatar May 28 '22 07:05 squaresoft2015

Can you please start from a fresh virtual environment? Conda is preferred. Does the error still occur?

FabianIsensee avatar Aug 23 '22 08:08 FabianIsensee

I have install PyTorch with command "pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116" before applying installation of nnUNet. The error remains the same.

Hi, do you solve the problem? I have the same error "importlib.metadata.PackageNotFoundError: No package metadata was found for nnunetv2"

I created a new environment and then I installed PyTorch with the command "conda install pytorch torchvision -c pytorch". But I still got the same error.

limyemily avatar May 16 '23 10:05 limyemily

Hey @limyemily,

sounds like you did not install nnunetv2 yet. As previously mentioned: pip install -e . (with conda/virtualenv active in the root directory of nnunet (the one that contains setup.py or pyproject.toml)).

Best, Tassilo

TaWald avatar Aug 09 '23 11:08 TaWald

Closing due to inactivity.

TaWald avatar Aug 21 '23 08:08 TaWald