I have opened a remote github repository in vs code that contains a project for uni. The structure of the project is as follows:
walking_panda
└──__init__.py
└── cli.py
└── panda.py
walking_panda.py
walking_panda.py contains the following code:
#!/usr/bin/env python
from walking_panda.cli import cli
if __name__ == '__main__':
cli()
When executing the file it returns this error:
ModuleNotFoundError: No module named 'walking_panda'
Is there something wrong with my from statement, or is it to do with the fact that the files are in a remote repository and not actually stored on my computer? I am also running using the Jupyter Interactive extension on vs code if that makes any difference. Also using linux mint.
Chances are that the file
walking_panda.py
is executed from another directory than the one it is located. If you can modify it, try to add:That should show from where
python
is called and if there is the modulewalking_panda
in this same place. For info, the current working directory (wherepython
is executed from) is inserted at index 0 of thesys.path
, which lists all the directories where modules can be imported from.