I have a python package called mltester
which contains two sub-packages (actions
, dialogs
) and a main script ml_tester.py
, structured as follows:
+ <ProjectFolder>
+---+ <mltester>
| +---- <actions>
| +---- <dialogs>
| +---- ml_tester.py
| +---- __init__.py
+---- setup.py
My __init__.py
looks as follows:
import actions
import dialogs
import ml_tester
In ml_tester.py
I do something like:
from actions import *
from dialogs import *
All works fine when running from eclipse. When doing pip install
, the following setup.py
works fine:
from setuptools import setup
setup(
name="MLTester",
version="1.0",
packages=["mltester",
"mltester.actions",
"mltester.dialogs"],
install_requires=[
"matplotlib",
],
entry_points='''
[console_scripts]
ml_tester_gui=mltester.ml_tester:main
'''
)
But when I remove "mltester.actions"
, "mltester.dialogs"
from the list of packages, I now get an error like:
File "/usr/local/lib/python2.7/dist-packages/mltester/__init__.py", line 1, in <module>
import actions
ImportError: No module named actions
And I don't understand why listing just the containing mltester
package is not enough. Of Course I can simply add the packages back, but now I think that I'm missing something more conceptual here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…