Since I decided to make 4 files with each one class instead of 1 file with all classes inside, I had trouble with the imports. I finally got the answers and I can give you some tips here.
First I got the error :
ImportError: cannot import name bidule
This was because I had a file name init.py instead of __init__.py in my package folder (@KtorZ you should update all your Python packages).
Second, when importing from outside of the package, I got the error :
ImportError: No module named truc
This time it was because inside some file, I imported truc with the command import truc but the python path did not included the directory path in which truc was since I originally imported the files from outside the package. In order to correct that error you should add the following lines in your __init__.py file :
import sys
import os
current_folder = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_folder)
One last remark : circular imports are not allowed in Python.
Since I decided to make 4 files with each one class instead of 1 file with all classes inside, I had trouble with the imports. I finally got the answers and I can give you some tips here.
First I got the error :
This was because I had a file name
init.py
instead of__init__.py
in my package folder (@KtorZ you should update all your Python packages).Second, when importing from outside of the package, I got the error :
This time it was because inside some file, I imported truc with the command
import truc
but the python path did not included the directory path in whichtruc
was since I originally imported the files from outside the package. In order to correct that error you should add the following lines in your__init__.py
file :One last remark : circular imports are not allowed in Python.