Kubespray: File "contrib/inventory_builder/inventory.py", line 38, in <module>

Created on 8 Apr 2019  路  16Comments  路  Source: kubernetes-sigs/kubespray

I鈥榤 working on k8s HA,but when I input :CONFIG_FILE=inventory/mycluster/hosts.ini python3 contrib/inventory_builder/inventory.py ${IPS[@]};

The error message came out,which is:
Traceback (most recent call last):
File "contrib/inventory_builder/inventory.py", line 38, in
from ruamel.yaml import YAML
ModuleNotFoundError: No module named 'ruamel'

I hope someone could help me out.

kinsupport lifecyclrotten

Most helpful comment

try pip3 install -r requirements.txt

All 16 comments

It looks like you need to pip install -r requirements.txt

/triage support

try pip3 install -r requirements.txt

It failed for me too. pip install didin't solve the issue in HEAD and v2.9.0. I had to checkout to v2.8.5 to get it working.

Besides the aforementioned error, there is no hosts.ini in HEAD's inventory/sample.

try pip3 install -r requirements.txt

Not working.

try pip3 install -r requirements.txt

It worked for me on Fedora 30.
tnx

I'm using the Dockerfile and got the same problem, it should be updated to work out-of-the-box.

try pip3 install -r requirements.txt

Working on Ubuntu 19.04

Old message: "Same issue here with release-2.11 and using virtualenv on Python 2.7.10 in OSX.
Installed requirements.txt into the clean and empty virtualenv created with: virtualenv $NAME
ruamel.yaml 0.15.96"

New Message:

Finally I find it by solving the issue with the user ( me )
ofc i have to use the python instead of python 3 as an command.

so maybe the other users can also verify it it was an issue in front of the pc.

Python2:
CONFIG_FILE=inventory/$FOLDER/hosts.yml python contrib/inventory_builder/inventory.py ${IPS[@]}
Python3:
CONFIG_FILE=inventory/kubeh/hosts.yml python3 contrib/inventory_builder/inventory.py ${IPS[@]}

Basically the README.md must be adapted to use one specific python version instead of mixing up or missing a version reference

On CentOS 7 it is broken too.
Resolve with:
python3.6 -m ensurepip
pip3 install -r requirements.txt

Notice that on a CentOS 7 system, python2 is the default python. When using pip install -r requirements.txt the modules will be installed for python2, but the script "inventory.py" is a python3 script. Hence (under CentOS 7), the python3 modules need to be installed using pip3.

This is going to change under RHEL 8 and CentOS 8, where python3 will be the default python.

sudo pip3 install ruamel.yaml
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting ruamel.yaml
  Downloading https://files.pythonhosted.org/packages/fa/90/ecff85a2e9c497e2fa7142496e10233556b5137db5bd46f3f3b006935ca8/ruamel.yaml-0.16.5-py2.py3-none-any.whl (123kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 133kB 1.2MB/s 
Collecting ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.8" (from ruamel.yaml)
  Downloading https://files.pythonhosted.org/packages/53/77/4bcd63f362bcb6c8f4f06253c11f9772f64189bf08cf3f40c5ccbda9e561/ruamel.yaml.clib-0.2.0-cp36-cp36m-manylinux1_x86_64.whl (548kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 552kB 486kB/s 
Installing collected packages: ruamel.yaml.clib, ruamel.yaml
Successfully installed ruamel.yaml-0.16.5 ruamel.yaml.clib-0.2.0
CONFIG_FILE=inventory/mycluster/hosts.yml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
DEBUG: Adding group all
DEBUG: Adding group kube-master
DEBUG: Adding group kube-node
DEBUG: Adding group etcd
DEBUG: Adding group k8s-cluster
DEBUG: Adding group calico-rr
DEBUG: adding host node1 to group all
DEBUG: adding host node2 to group all
DEBUG: adding host node3 to group all
DEBUG: adding host node1 to group etcd
DEBUG: adding host node2 to group etcd
DEBUG: adding host node3 to group etcd
DEBUG: adding host node1 to group kube-master
DEBUG: adding host node2 to group kube-master
DEBUG: adding host node1 to group kube-node
DEBUG: adding host node2 to group kube-node
DEBUG: adding host node3 to group kube-node

still not work on centos 7

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Was this page helpful?
0 / 5 - 0 ratings