sassoftware / viya4-deployment

This project contains Ansible code that creates a baseline in an existing Kubernetes environment for use with the SAS Viya Platform, generates the manifest for an order, and then can also deploy that order into the Kubernetes environment specified.
Apache License 2.0
71 stars 64 forks source link

ImportError: cannot import name 'main' #284

Closed jawilk23 closed 10 months ago

jawilk23 commented 2 years ago

Attempting to add users to an internal account when I received an error:

"Failed to import the required Python library (openshift) on cldlgn05.unx.sas.com's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"

I realized there had been a new project released yesterday, so I cloned the new project and while executing:

ansible-galaxy collection install -r requirements.yaml -f ansible-galaxy role install -r requirements.yaml -f

Received the following error:

File "/usr/local/bin/ansible-playbook", line 5, in from ansible.cli.playbook import main ImportError: cannot import name 'main' from 'ansible.cli.playbook' (/r/ge.unx.sas.com/vol/vol410/u41/jawilk/.local/lib/python3.10/site-packages/ansible/cli/playbook.py)

jawilk23 commented 2 years ago

I did also perform the pip3 install --user -r requirements.txt command before the ansible-galaxy commands.

jawilk23 commented 2 years ago

Contents of ansible-galaxy file:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from ansible.cli.galaxy import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
thpang commented 2 years ago

If you have both python 2 and python 3 on your system you have to make sure that python 3 is the default version for both the python and pip executables.

jawilk23 commented 2 years ago

Python 3.10 is the default for both pip and python executables, yet I am still getting the same error.

thpang commented 2 years ago

Seems like an ansible issue. I'd say find another system and try fresh with python3 pip3 and ansible in a clean state.

dhoucgitter commented 10 months ago

Marking as stale/inactive. If there are additional questions, please open a new Github issue.

dhoucgitter commented 10 months ago

Closing #284 as completed.