title: Cannot import a module
body: <p>I'm relatively new to Python and am trying to import some modules that were written by a 3rd party. They are called ok.py and _ok.pyd. I am trying to 'import ok', which references _ok.pyd, but it is not working. They are both in my site-packages directory, and I've added that path name to my Spyder PYTHONPATH variable. I've also tried putting them both in the current working directory, but to no avail.</p>
  <p>All I do is type 'import ok' and I get the following error messages.</p>
  <blockquote>
  <p>Traceback (most recent call last):</p>
  <p>File &quot;D:\Anaconda3\Lib\site-packages\ok.py&quot;, line 15, in
  swig_import_helper
  return importlib.import_module(mname)</p>
  <p>File &quot;D:\Anaconda3\lib\importlib_<em>init</em>_.py&quot;, line 127, in
  import_module
  return _bootstrap._gcd_import(name[level:], package, level)</p>
  <p>File &quot;&quot;, line 1006, in _gcd_import</p>
  <p>File &quot;&quot;, line 983, in _find_and_load</p>
  <p>File &quot;&quot;, line 967, in
  _find_and_load_unlocked</p>
  <p>File &quot;&quot;, line 670, in _load_unlocked</p>
  <p>File &quot;&quot;, line 583, in module_from_spec</p>
  <p>File &quot;&quot;, line 1043, in
  create_module</p>
  <p>File &quot;&quot;, line 219, in
  _call_with_frames_removed</p>
  <p>ImportError: DLL load failed: The specified module could not be found.</p>
  <p>During handling of the above exception, another exception occurred:</p>
  <p>Traceback (most recent call last):</p>
  <p>File &quot;&quot;, line 1, in 
  import ok</p>
  <p>File &quot;D:\Anaconda3\Lib\site-packages\ok.py&quot;, line 18, in 
  _ok = swig_import_helper()</p>
  <p>File &quot;D:\Anaconda3\Lib\site-packages\ok.py&quot;, line 17, in
  swig_import_helper
  return importlib.import_module('_ok')</p>
  <p>File &quot;D:\Anaconda3\lib\importlib_<em>init</em>_.py&quot;, line 127, in
  import_module
  return _bootstrap._gcd_import(name[level:], package, level)</p>
  <p>ImportError: DLL load failed: The specified module could not be found.</p>
  </blockquote>
  <p>The following is the ok.py code where it fails. I've done an image so line numbers are visible.</p>
  <p><a href="https://i.stack.imgur.com/Qiu5I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qiu5I.png" alt="ok.py" /></a></p>
  <p>Is there something easy I'm missing here, or is it unsolvable without the 3rd party vendor updating their code? It just looks like the importlib.import_module() cannot find _ok, but it is in the directory. When I type importlib.import_module() for other module names in that directory it works, so what are possible causes for this one not working?</p>
  <p>Thank you.</p>