KnowledgeBase Content Details

July 13, 2017

Question:

IronPython.Runtime.Exceptions.ImportException: No module named os.path

Answer:


Trying to import the os.path Python module in Spotfire fails with the error -IronPython.Runtime.Exceptions.ImportException: No module named os.path The OS module is not seem a part of the Spotfire Python module so it fails to load and cannot be used in the Spotfire Python scripts.

Resolution

The .NET module System.IO can be used for any file related operations. For example, to check if a file exists in a directory, use the following snippet:

from System.IO import File

path = r'c:\temp\myfile.txt'

print 'File Exists: %s' % File.Exists(path)

Back to KnowledgeBase