title: KeyError / frozen importlib._bootstrap error on second library import in spyder
body: <p>I receive a </p>
  
  <pre><code>File " &lt;frozen importlib._bootstrap_external&gt; ", line 978, in _get_parent_path    
  KeyError: 'python_library'
  </code></pre>
  
  <p>error when I import a library from a subfolder the second time in spyder, but the first time (after restarting spyder) or outside of spyder it works fine.</p>
  
  <p>The code is:</p>
  
  <pre><code>from python_library.tools.test_lib import test_func    
  test_func()
  </code></pre>
  
  <p>where test_lib.py is simply</p>
  
  <pre><code>def test_func():    
      print('Hello!')
  </code></pre>
  
  <p>And the output is:</p>
  
  <pre><code>runfile('/home/user/Desktop/test.py', wdir='/home/user/Desktop')
  Hello!
  
  runfile('/home/user/Desktop/test.py', wdir='/home/user/Desktop')    
  Reloaded modules: python_library, python_library.tools.test_lib
  Traceback (most recent call last):
  
    File "&lt; ipython-input-2-e750fd08988c &gt;", line 1, in &lt;module&gt;   
      runfile('/home/user/Desktop/test.py', wdir='/home/user/Desktop')
  
    File "/home/user/anaconda3/envs/qutip/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 678, in runfile    
      execfile(filename, namespace)
  
    File "/home/user/anaconda3/envs/qutip/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 106, in execfile
      exec(compile(f.read(), filename, 'exec'), namespace)
  
    File "/home/user/Desktop/test.py", line 1, in &lt;module&gt;
      from python_library.tools.test_lib import test_func
  
    File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  
    File "&lt;frozen importlib._bootstrap&gt;", line 951, in _find_and_load_unlocked
  
    File "&lt;frozen importlib._bootstrap&gt;", line 894, in _find_spec
  
    File "&lt;frozen importlib._bootstrap_external&gt;", line 1157, in find_spec
  
    File "&lt;frozen importlib._bootstrap_external&gt;", line 1123, in _get_spec
  
    File "&lt;frozen importlib._bootstrap_external&gt;", line 994, in __iter__
  
    File "&lt;frozen importlib._bootstrap_external&gt;", line 982, in _recalculate
  
    File "&lt;frozen importlib._bootstrap_external&gt;", line 978, in _get_parent_path
  
  KeyError: 'python_library'
  </code></pre>
  
  <p>The error does not occur when the library is not in a subfolder i.e.</p>
  
  <pre><code>from python_library.test_lib2 import test_func
  </code></pre>
  
  <p>runs arbitrarily often. However I have enough functions that not having subfolders would be very annoying.</p>
  
  <p>This was with spyder-3.3.2, but it also occurred earlier with spyder version 3.3.0-py36_1. The python version is 3.6.4., spyder is installed and updated via anaconda and the 'python_library' was installed via setup.py (setuptools version 40.6.3, also occurred with version 39.2.0-py36_0).</p>
  
  <p>Note: The same error occurred in question 
  <a href="https://stackoverflow.com/questions/46439836/how-do-i-solve-a-keyerror-when-importing-a-python-module">How do I solve a KeyError when importing a python module?</a>
  but that question has no answer, and also no spyder tag.</p>