在我的python项目中,我具有此层次结构
+ slack_app
+ src
+ apps
+ intro
+ \__main__.py
+ slack_app.py
+ setup.py
这是我的setup.py:
setup(
name= "my-slack-app",
packages = find_packages(),
entry_points = {
'console_scripts': [
'slack-app = src.apps.intro.__main__:main',
],
})
__ main __。py:
def main():
print("WORKED")
if __name__ == "__main__":
main()
我先运行python3 setup.py install,然后运行安装在/usr/local/python3.6/bin中的我的应用程序,但在运行它时总是会收到此错误:
Traceback (most recent call last):
File "/usr/local/python3.6/bin/slack-app", line 11, in <module>
load_entry_point('my-slack-app==0.1.dev2+g4fd21b0.d20200309',
'console_scripts', 'slack-app')()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2854, in
load_entry_point
return ep.load()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'],
level=0)
ModuleNotFoundError: No module named 'src.apps'
请帮忙吗?
答案 0 :(得分:1)
如果您使用的是setuptools.find_packages
,则需要拥有__init__.py
文件。另外,您正在使用所谓的 src-layout ,因此需要调整package_dir
并设置where
的{{1}}参数。
参考: