尝试在 Kaggle 中加载模块 pynrrd 时出现导入错误

I am having an import error while trying to load the module pynrrd in Kaggle

对不起,这是一个简单的问题,但我是 Python 的新手。我正在尝试在 Kaggle 中加载模块 "pynrrd"。我收到导入错误,我不确定为什么。

这是我正在测试的代码:

# Required modules
import numpy as np 
!pip install pynrrd
import matplotlib.pyplot as plt
import matplotlib
import tensorflow as tf
import time
import os
import sys
import pydicom
import pynrrd
import scipy.ndimage
import scipy.misc
import pickle
import random
import skimage
%matplotlib notebook

if sys.version_info[0] != 3:
    raise Exception("Python version 3 has to be used!")

print("Currently using")
print("\t numpy ", np.__version__)
print("\t scipy ", scipy.__version__)
print("\t matplotlib ", matplotlib.__version__)
print("\t tensorflow ", tf.__version__)
print("\t pydicom ", pydicom.__version__)
print("\t nrrd ", nrrd.__version__)
print("\t skimage ", skimage.__version__)

np.random.seed(37) # for reproducibility

错误信息如下:

Collecting pynrrd
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f344e3d36d8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pynrrd/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f344e3d3668>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pynrrd/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f344e3d3550>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pynrrd/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f344e3d32b0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pynrrd/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f344e3d3358>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /simple/pynrrd/
  Could not find a version that satisfies the requirement pynrrd (from versions: )
No matching distribution found for pynrrd
ImportError                               Traceback (most recent call last)
<ipython-input-4-0f6894d371c4> in <module>()
     10 import sys
     11 import pydicom
---> 12 import pynrrd
     13 import scipy.ndimage
     14 import scipy.misc

ImportError: No module named 'pynrrd'

PS:我也尝试过使用 nrrd 而不是 pynrrd,但这也不起作用

您可能没有通过设置允许互联网

内核右侧

  1. 点击设置
  2. 将互联网切换为 "on"

您还会发现一个从设置安装软件包的选项

应该这样导入

import nrrd