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

时间:2019-06-09 00:35:50

标签: python package 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 个答案:

答案 0 :(得分:1)

您可能不允许设置访问互联网

在内核的右侧

  1. 点击设置
  2. 将Internet切换为“开启”

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

导入应像这样

No Python at 'c:\python 37\python37-32\python.exe'