我创建了一个具有以下层次结构的python模块
Git存储库:Zeus | Machine Learning Library
但是只要我运行命令
python setup.py install
它成功安装了模块,但是当我尝试从子模块中导入任何内容时,会出现错误。
当我在python终端中运行它时
import zeus
它完全可以正常工作,但是当我运行它时
from zeus.tree import classifiers
它给我以下错误
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from zeus.tree import classifiers
ModuleNotFoundError: No module named 'zeus.tree'
我猜这是我的 init .py问题,但不知道它到底是什么。
答案 0 :(得分:2)
# -*- coding: utf-8 -*-
from distutils.core import setup
setup(
name = "zeus",
version = "0.1",
author = "yourname",
author_email = "youraddress@xyz.com",
description = ("A simple and easy to use Machine Learning Library."),
license = "GPL-2,0",
packages=['zeus', 'zeus.tree', 'zeus.linear_regressors'],
install_requires=['numpy'],
zip_safe=False
)
Your packaging didn't include the sub modules which is causing the import error. The changed line is:
packages=['zeus', 'zeus.tree', 'zeus.linear_regressors']
Instead you only had:
packages=['zeus']