0

I'm trying to execute a code which displays the file format of a particular path.

But I'm getting the following error, related to the path specified. The file which is executing in 'C:\Research\LungCancerDetaction\Preprocessing2.py' folder.

The 'input' folder is in path, C:\Research\input.

The following is the code written.

    import numpy as np # Linear algebra
    import pandas as pd # Data processing, CSV file I/O (e.g. pd.read_csv)
    import skimage, os
    from skimage.morphology import ball, disk, dilation, binary_erosion, remove_small_objects, erosion, closing, reconstruction, binary_closing
    from skimage.measure import label,regionprops, perimeter
    from skimage.morphology import binary_dilation, binary_opening
    from skimage.filters import roberts, sobel
    from skimage import measure, feature
    from skimage.segmentation import clear_border
    from skimage import data
    from scipy import ndimage as ndi
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d.art3d import Poly3DCollection
    import dicom
    import scipy.misc
    import numpy as np

    # Input data files are available in the "../input/" directory.
    # For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory

    import subprocess
    print(subprocess.check_output(["ls", "../input"]).decode("utf8"))

But I'm getting the error,

    Traceback (most recent call last):
      File "C:/Research/LungCancerDetaction/Preprocessing2.py", line 22, in <module>
        print(subprocess.check_output(["ls", "../input"]).decode("utf8"))
      File "C:\Research\Python_installation\lib\subprocess.py", line 626, in check_output
        **kwargs).stdout
      File "C:\Research\Python_installation\lib\subprocess.py", line 693, in run
        with Popen(*popenargs, **kwargs) as process:
      File "C:\Research\Python_installation\lib\subprocess.py", line 947, in __init__
        restore_signals, start_new_session)
      File "C:\Research\Python_installation\lib\subprocess.py", line 1224, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the file specified

How do I figure out the error?

1
  • Why do you need so many imports to execute a single line? Commented Sep 2, 2017 at 12:12

1 Answer 1

1

Delete this line...

print(subprocess.check_output(["ls", "../input"]).decode("utf8"))

... and use this instead:

import os

print(os.listdir('../input'))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.