Search code examples
pythonpackagekaggle

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


Excuse me if this is a simple question, but I'm new to Python. I'm trying to load the module "pynrrd" in Kaggle. I am getting import errors, I'm not sure why.

Here is the code I'm testing:

# 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

Here are the error messages:

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: I also tried nrrd instead of pynrrd but that didn't work either


Solution

  • You probably didn't allow internet from settings

    On the right side of the kernel

    1. Click settings
    2. Toggle Internet to "on"

    You'll find also an option to install packages from settings

    The import should be done like this

    import nrrd