我在尝试在 Kaggle 中加载模块 pynrrd 时遇到导入错误



如果这是一个简单的问题,请原谅我,但我是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. 将互联网切换为"开启">

您还将找到从设置中安装软件包的选项

导入应该像这样完成

import nrrd

相关内容

最新更新