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

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

book

Article ID: KB0083876

calendar_today

Updated On:

Products Versions
Spotfire Analyst 7.0,7.5,7.6,7.7,7.8,7.9

Description

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.

Issue/Introduction

When import os.path module in Spotfire Iron Python fails with error No module named os.path

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)

Additional Information

https://msdn.microsoft.com/en-us/library/system.io.file(v=vs.110).aspx