Ich erhalte eine < /p>
File " ", line 978, in _get_parent_path
KeyError: 'python_library'
< /code>
Fehler Wenn ich eine Bibliothek zum zweiten Mal in Spyder aus einem Unterordner importiere, aber beim ersten Mal (nach Neustart von Spyder) oder außerhalb von Spyder funktioniert es gut.from python_library.tools.test_lib import test_func
test_func()
< /code>
wobei test_lib.py einfach < /p>
istdef test_func():
print('Hello!')
< /code>
und die Ausgabe lautet: < /p>
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 "< ipython-input-2-e750fd08988c >", line 1, in
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
from python_library.tools.test_lib import test_func
File "", line 971, in _find_and_load
File "", line 951, in _find_and_load_unlocked
File "", line 894, in _find_spec
File "", line 1157, in find_spec
File "", line 1123, in _get_spec
File "", line 994, in __iter__
File "", line 982, in _recalculate
File "", line 978, in _get_parent_path
KeyError: 'python_library'
< /code>
Der Fehler tritt nicht auf, wenn sich die Bibliothek nicht in einem Unterordner befindet, d. H. < /p>
from python_library.test_lib2 import test_func
< /code>
führt häufig willkürlich aus. Ich habe jedoch genügend Funktionen, dass die Nicht-Unterordner sehr ärgerlich wären. Die Python-Version ist 3.6.4. Spyder wird über Anaconda installiert und aktualisiert und das 'Python_library' wurde über Setup.py installiert (setuptools Version 40.6.3, auch mit Version 39.2.0-Py36_0 aufgetreten. Python -Modul?
Aber diese Frage hat keine Antwort und auch kein Spyder -Tag. < /p>
KeyError / Frozen Importlib._bootstrap Fehler beim zweiten Bibliothek importieren in Spyder ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post