[英]Auto-complete does not work for user with argcomplete
The auto-completion feature does not seem to work for me.自动完成功能似乎对我不起作用。 I created a small test script that reproduces the problem on my setup (Ubuntu 20.04, bash 5.0.17, python 3.8):我创建了一个小测试脚本,在我的设置中重现了问题(Ubuntu 20.04、bash 5.0.17、python 3.8):
#!/usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
import argparse
import argcomplete
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Parser test')
parser.add_argument('-p', '--port', type=int, default=1346)
parser.add_argument('--host', default='localhost')
argcomplete.autocomplete(parser)
parser.parse_args()
I have install argcomplete by running pip3 install argcomplete
and activated it by running activate-global-python-argcomplete --user
.我已经通过运行pip3 install argcomplete
了 argcomplete 并通过运行activate-global-python-argcomplete --user
来激活它。 What am I missing?我错过了什么?
Whilst writing this question I found that for python3 I should be using sudo activate-global-python-argcomplete3
followed by exec bash
to enable it.在写这个问题时,我发现对于 python3,我应该使用sudo activate-global-python-argcomplete3
后跟exec bash
来启用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.