我创建了一个程序,其setup.py导入setuptools并包含:
scripts=['scripts/vibez'],
目录的布局如下
projectdirectory
├── __init__.py
├── main.py
└── scripts
└── vibez
vibez脚本包括:
#!python
import vibez
vibez.start_vibez()
__init__
脚本包括:
from main import execute
def start_vibez():
main()
main.py文件在底部注释:
if __name__ == '__main__':
execute()
我使用python setup.py install.
我执行vibez
并成功运行__init__
文件。
好像找不到__init__
文件的main导入,我得到了:
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/vibez", line 4, in <module>
__import__('pkg_resources').run_script('vibez==0.78', 'vibez')
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 735, in run_script
self.require(requires)[0].run_script(script_name, ns)
ImportError: No module named 'main'
为什么会这样?