title: Loading DLL from embedded python code in c
body: <p>The crux of my problem is this:</p>
  
  <p>I am developing code on Windows XP in C with MS Visual Studio 10.0, and I need to embed Python to do some plotting, file management, and some other things.  I had problems with sys.path finding my Pure-Python modules, but I have fixed the problem by modifying PYTHONPATH.</p>
  
  <p>Now, my problem is getting python to find dynamic libraries that are pulled in by some modules.  In particular, my problem is to compress a folder into a bzip2 achive of the same name.</p>
  
  <p>From a normal python command prompt, this works just fine:</p>
  
  <pre><code>import tarfile
  tar=tarfile.open('Code.tar.bz2','w:bz2')
  tar.add('Code',arcname='Code')
  tar.close()
  </code></pre>
  
  <p>But when I call this code from my c-code, it gives me this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;string&gt;", line 4, in &lt;module&gt;
    File "D:\My_Documents\Code\ScrollModel\trunk\PythonCode.py", line 20, in Colle
  ctFiles
      tar=tarfile.open(os.path.join(runPath,'CODE.tar.bz2'),'w:bz2')
    File "c:\Python26\lib\tarfile.py", line 1671, in open
      return func(name, filemode, fileobj, **kwargs)
    File "c:\Python26\lib\tarfile.py", line 1737, in bz2open
      raise CompressionError("bz2 module is not available")
  tarfile.CompressionError: bz2 module is not available
  </code></pre>
  
  <p>I have a suspicion the problem is similar to what is described at section 5.6 of <a href="http://docs.python.org/release/2.6.6/extending/embedding.html" rel="nofollow">Embedded Python</a>, but it is a bit hard to tell.  For what its worth, if I do</p>
  
  <pre><code>Py_Initialize();
  PyRun_SimpleString("import ssl\n");
  Py_Finalize();
  </code></pre>
  
  <p>it doesn't work either and I get an ImportError.</p>
  
  <p>Anyone had any problems like this?  Am I missing something critical?</p>