I have followed the instructions in the Openstack Documentation here to install the openstack CLI. When I was done installing Python 2.7.18 and python-openstackclient, I ran the command openstack in powershell and I get the following error:
Traceback (most recent call last):
File "C:\Python27\Scripts\openstack-script.py", line 11, in <module>
load_entry_point('python-openstackclient==5.2.2', 'console_scripts', 'openstack')()
File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2852, in load_entry_point
return ep.load()
File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2443, in load
return self.resolve()
File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 2449, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\python27\lib\site-packages\openstackclient\shell.py", line 22, in <module>
from osc_lib.api import auth
File "c:\python27\lib\site-packages\osc_lib\api\auth.py", line 18, in <module>
from keystoneauth1.identity.v3 import k2k
File "c:\python27\lib\site-packages\keystoneauth1\identity\__init__.py", line 14, in <module>
from keystoneauth1.identity import generic
File "c:\python27\lib\site-packages\keystoneauth1\identity\generic\__init__.py", line 14, in <module>
from keystoneauth1.identity.generic.password import Password # noqa
File "c:\python27\lib\site-packages\keystoneauth1\identity\generic\password.py", line 16, in <module>
from keystoneauth1.identity import v3
File "c:\python27\lib\site-packages\keystoneauth1\identity\v3\__init__.py", line 26, in <module>
from keystoneauth1.identity.v3.oauth2_client_credential import * # noqa
File "c:\python27\lib\site-packages\keystoneauth1\identity\v3\oauth2_client_credential.py", line 119
headers['Authorization'] = f'Bearer {oauth2_token}'
I inspected the file and saw the line it's complaining about. After a quick google, I saw that it was reported and fixed in 2022 as you can see here. Then I ran command pip install --upgrade python-openstackclient to update the package to latest, but I am still getting the same error. I downloaded and install python 3 (Although Openstack documentation says: Currently, the clients do not support Python 3.) to see if maybe there was a package dependency on it, but the results are the same.
I see in the PR here, there as a change made to the setup.cfg file, but I am unable to find a file with that name in my local files where the libraries are installed to confirm I have the latest. Could anyone offer any guidance on how to resolve this issue? is there a step missing in the openstack documentation that I should be aware of? I am assuming after installing the packages I shouldn't have to go in and modify any files.
This is incorrect. You are reading the OSC documentation from the Newton release. It is 7+ years out of date ... and not applicable to the latest versions of OpenStack.
How do I know?
I do OpenStack programming in python 3 every day ... including using many of the client OS python clients.
The last line of stacktrace shows this line of code:
That is using f-string syntax that was first introduced in Python 3.6.
In fact, the stacktrace is happening because you are running python 3.6+ code on python 2.7.
And one more piece of evidence is this page which lists the Python 3 status of all of the openstack python client libraries.
My advice: read the latest documentation and start again with a clean python 3 install. And more generally, always check that you are using the correct version of the OpenStack documentation ... not just the version the Google finds for you first.
Notes:
pip3instead ofpipto install into a python3 installation. Though that depends on how you installed Python.virtual-envfor your OpenStack work so that the dependencies installed with the OpenStack don't mess up things for other unrelated python applications.