Amazon EC2 AMI linux2 amazon-linux-extras basearch 错误

Amazon EC2 AMI linux2 amazon-linux-extras basearch 错误
sudo amazon-linux-extras install
Traceback (most recent call last): 
  File "/usr/lib64/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/amazon_linux_extras/__main__.py", line 35, in <module>
    sys.exit(cli_main([arg for arg in argv[1:] if arg != "-v"]))
  File "/usr/lib/python2.7/site-packages/amazon_linux_extras/cli.py", line 419, in main
    action(args)
  File "/usr/lib/python2.7/site-packages/amazon_linux_extras/cli.py", line 245, in cmd_install
    catalog = get_catalog(insist_stable_ordinal=any(re.match(r"^[0-9]+$", arg) for arg in args))
  File "/usr/lib/python2.7/site-packages/amazon_linux_extras/software_catalog.py", line 120, in get_catalog
    catalog = fetch_new_catalog()  
  File "/usr/lib/python2.7/site-packages/amazon_linux_extras/software_catalog.py", line 92, in fetch_new_catalog
    url = CATALOG_URL.format(**yumvars)
KeyError: u'basearch'

收到此错误,提示 Basesearch 关键字错误。必须安装 nginx

答案1

Sijo James John 的回答basearch突出显示了将 设置为默认值的问题None,但还有一种修改software_catalog.py文件的替代方法。该文件中的代码会检查每个与全大写键名匹配的键的环境变量覆盖。在这种情况下,设置BASEARCH将覆盖。在我的情况下,basearch需要是x86_64

我也默认使用 python 3,但amazon-linux-extras由于使用,需要 python 2.7 yum。幸运的是,在使用默认命令之前amazon-linux-extras也会查找环境变量覆盖。PYTHONpython

下面是在我的计算机上成功运行的示例命令:

PYTHON=python2 BASEARCH=x86_64 amazon-linux-extras list

答案2

好吧,问题解决了

首先使用此代码找到基础拱门

python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'

{'arch': 'ia32e',

'awsdomain':'amazonaws.com','awsregion':'eu-*****','basearch':'x86_64','product':'core','releasever':'2','target':'latest','uuid':'**************'}

然后编辑

nano /usr/lib/python2.7/site-packages/amazon_linux_extras/software_catalog.py

改变路线

for name, default in (("awsdomain", "amazonaws.com"), ("awsregion", "default"), ("releasever", "2"), ("basearch", None)):

for name, default in (("awsdomain", "amazonaws.com"), ("awsregion", "default"), ("releasever", "2"), ("basearch", "x86_64")):

问题是基础搜索默认值为 None,这导致字典没有键值对基础搜索

相关内容