问题描述
我可能又犯了一个愚蠢的错误。但是我找不到它。即使在这个极小的最小(不是)工作示例中……
文件夹结构:
setup.py
x_module
__init__.py
main.py
setup.py
包含
from setuptools import setup
setup(
name= 'setup-test',version='0.1',py_modules = ['x_module' ],entry_points = '''
[console_scripts]
x_test=x_module.main:main
'''
)
__init__.py
为空
main.py
包含
#!/usr/bin/env python3
def main():
print('x_module.main.main() executed')
命令行输出:
$ pip install .
Processing /workspaces/setup_py_test
Building wheels for collected packages: setup-test
Building wheel for setup-test (setup.py) ... done
Created wheel for setup-test: filename=setup_test-0.1-py3-none-any.whl size=1263 sha256=52c02b70254467e4d10955dc520b692a320f93c858e77711f77b0ab286f422d5
Stored in directory: /tmp/pip-ephem-wheel-cache-miymlm3k/wheels/a1/08/94/6f5e7ee293420487584919e807df93ea4d84adc23ab40faf00
Successfully built setup-test
Installing collected packages: setup-test
Attempting uninstall: setup-test
Found existing installation: setup-test 0.1
Uninstalling setup-test-0.1:
Successfully uninstalled setup-test-0.1
Successfully installed setup-test-0.1
$ x_test
Traceback (most recent call last):
File "/usr/local/bin/x_test",line 5,in <module>
from x_module.main import main
ModuleNotFoundError: No module named 'x_module'
奇怪的是它在可编辑模式下工作:
$ pip install -e .
Obtaining file:///workspaces/setup_py_test
Installing collected packages: setup-test
Attempting uninstall: setup-test
Found existing installation: setup-test 0.1
Uninstalling setup-test-0.1:
Successfully uninstalled setup-test-0.1
Running setup.py develop for setup-test
Successfully installed setup-test
$ x_test
x_module.main.main() executed
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)