Reputation: 556
I have started to program an rpg game in python 3. Here is the error I get when running it:
Traceback (most recent call last):
File "main.py", line 3, in <module>
from characters.player import *
File "/home/darcey/python/characters/player.py", line 2, in <module>
from character import *
ImportError: No module named 'character'
Here is my file structure:
| = folder
~ = file
| python
| characters
~ __init__.py
~ player.py
~ character.py
~ enemy.py
~ main.py
If I need to put all the code in or code from certain files just comment below and I'll add them.
Upvotes: 0
Views: 60
Reputation: 1122232
You need to use a package relative import:
from .character import *
Note the .
; you don't have a global character
module, only a local one.
Alternatively, use an absolute import:
from characters.character import *
Upvotes: 3