Struktur Programm
│ ├── common
│ │ ├── __init__.py
│ │ ├── modul1.py
│ │ ├── modul2.py
│ │ └── modul3.py
│ └── tests
│ ├── __init__.py
│ ├── test_modul1.py
│ ├── test_modul2.py
│ └── test_modul3.py
common/__init__.py:
__all__ = ['module1','modul2','modul3']
tests/__init__.py:
__all__ = [test_modul1','test_modul2','test_modul3']
tests/test_modul1.py:
from common.modul1 import func_modul1_1
func_modul1_1()
Fehlermeldung
headhunter1978:omission-git headhunter1978$ /usr/local/bin/python3 "/Users/headhunter1978/Library/Mobile Documents/com~apple~CloudDocs/omission-git/omission/tests/test_modul1.py"
Traceback (most recent call last):
File "/Users/headhunter1978/Library/Mobile Documents/com~apple~CloudDocs/omission-git/omission/tests/test_modul1.py", line 1, in <module>
from common.modul1 import func_modul1_1
ModuleNotFoundError: No module named 'common'
Ich möchte von tests/test_modul1.py auf common/test_modul1.py zu greifen. Unter pyCharm funktioniert das. Wenn ich das unter Visual Studio Code ausführe, bekomme ich folgende Meldung:
ModuleNotFoundError: No module named 'common'
Habt ihr eine Idee, was ich falsch mache?
Zugriff auf Package im Subfolder
- __blackjack__
- User
- Beiträge: 14012
- Registriert: Samstag 2. Juni 2018, 10:21
- Wohnort: 127.0.0.1
- Kontaktdaten:
Damit das funktioniert muss das Arbeitsverzeichnis das Verzeichnis sein in dem `common/` und `tests/` liegen.
“The best book on programming for the layman is »Alice in Wonderland«; but that's because it's the best book on anything for the layman.” — Alan J. Perlis
-
- User
- Beiträge: 20
- Registriert: Sonntag 18. November 2018, 11:15
Beide Verzeichnisse liegen im Arbeitsverzeichnis. Wie gesagt, das komische ist, dass es unter Pycharm läuft aber unter VSC nicht.