title: How do you use the standard library in IronPython?
body: <p>I'll prefix this question with: No, Setting IRONPYTHONPATH is not the answer.</p>
  
  <p>Anyway...</p>
  
  <p>I was planning on using IronPython as a replacement for Powershell for a project, but I've been stumped before I've even started.</p>
  
  <p>The very first thing I tried to do was use os.path, resulting in:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;string&gt;", line 1, in &lt;module&gt;
  ImportError: No module named os
  </code></pre>
  
  <p>After messing around I finally discovered I could use the standard library by adding it manually to the path:</p>
  
  <pre><code>import sys
  sys.path.append(r"C:\Program Files\IronPython 2.7\Lib")
  import os
  </code></pre>
  
  <p>However, this is a daft idea. Hard coding the path to the python library inside my scripts is a 100% guaranteed way of making them not work at some point.</p>
  
  <p>I discovered this almost immediately when I tried to use the script on a windows 7 machine and the path was slightly different ('Program Files (x86)').</p>
  
  <p>So, a couple of questions here:</p>
  
  <p>1) <strong>Why is it so hard to use the standard library?</strong> At the very least I would have thought the interactive prompt in VS and basic ipy.exe would have this. </p>
  
  <p>2) <strong>How can I determine the directory that iron python is installed in regardless of the system I'm using?</strong> (IronPython installer setting a var perhaps?)</p>
  
  <p>Just a note here; yes, I have seen some other posts saying "set your IRONPYTHONPATH". This in unhelpful. If I have a blank machine that means I have to:</p>
  
  <p>1) Install IronPython</p>
  
  <p>2) Run some crazy powershell script to search out where-ever-the-heck the standard library was installed and set a global IRONPYTHONPATH variable to it.</p>
  
  <p>3) Run python scripts</p>
  
  <p>I'm looking for a better way.</p>
  
  <p>--</p>
  
  <p>Edit: </p>
  
  <p>The fact I'm using this to do powershell like things is basically irrelevant, but I'm trying to achieve something like:</p>
  
  <pre><code>import clr
  from System.Management.Automation import RunspaceInvoke
  import os
  
  scriptRoot = os.getcwd()
  runSpace = RunspaceInvoke()
  cmdPath64 = os.join(scriptRoot, "..\java\...")
  cmdPath32 = os.join(scriptRoot, "..\java\...")
  proc = runSpace.Invoke("Get-WmiObject Win32_Processor ... ")
  if proc.AddressWidth == 32:
    runSpace.Invoke(cmdPath32)
  else:
    runSpace.Invoke(cmdPath64)
  </code></pre>