Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows initialization error #2399

Closed
lv123123long opened this issue Oct 9, 2023 · 2 comments · Fixed by #2407
Closed

windows initialization error #2399

lv123123long opened this issue Oct 9, 2023 · 2 comments · Fixed by #2407
Labels
bug dependencies Pull requests that update a dependency file

Comments

@lv123123long
Copy link

lv123123long commented Oct 9, 2023

When I used python-kafka under windows, I found that I did not have kerberos for windows installed locally. However, during initialization, I would look for this configuration and exit with an error.

my codes:

producer = KafkaProducer(bootstrap_servers = SERVER,
                                 security_protocol = 'PLAIN',
                                 sasl_mechanism = 'PLAIN',
                                 value_serializer = lambda m: json.dumps(m).encode(),
                                 api_version = (0, 10, 2)
                                 )

error:

from kafka import KafkaProducer
  File "D:\otherpython\python3810\lib\site-packages\kafka\__init__.py", line 21, in <module>
    from kafka.admin import KafkaAdminClient
  File "D:\otherpython\python3810\lib\site-packages\kafka\admin\__init__.py", line 4, in <module>
    from kafka.admin.client import KafkaAdminClient
  File "D:\otherpython\python3810\lib\site-packages\kafka\admin\client.py", line 13, in <module>
    from kafka.client_async import KafkaClient, selectors
  File "D:\otherpython\python3810\lib\site-packages\kafka\client_async.py", line 21, in <module>
    from kafka.cluster import ClusterMetadata
  File "D:\otherpython\python3810\lib\site-packages\kafka\cluster.py", line 12, in <module>
    from kafka.conn import collect_hosts
  File "D:\otherpython\python3810\lib\site-packages\kafka\conn.py", line 79, in <module>
    import gssapi
  File "D:\otherpython\python3810\lib\site-packages\gssapi\__init__.py", line 29, in <module>
    import gssapi._win_config  # noqa
  File "D:\otherpython\python3810\lib\site-packages\gssapi\_win_config.py", line 90, in <module>
    configure_windows()
  File "D:\otherpython\python3810\lib\site-packages\gssapi\_win_config.py", line 85, in configure_windows
    error_not_found()
  File "D:\otherpython\python3810\lib\site-packages\gssapi\_win_config.py", line 49, in error_not_found
    raise OSError(
OSError: Could not find KfW installation. Please download and install the 64bit Kerberos for Windows MSI from https://web.mit.edu/KERBEROS/dist and ensure the 'bin' folder (C:\Program Files\MIT\Kerberos\bin) is in your PATH.
@lv123123long
Copy link
Author

This is very unreasonable. I did not use Kerberos related protocols, but gssapi was introduced in copy.py and an error was thrown.

@wbarnha
Copy link
Collaborator

wbarnha commented Nov 3, 2023

I see your post in pythongssapi/python-gssapi#290, seems like the issue won't be getting fixed anytime soon.

Best I can do is add another exception handle for OSError beside ImportError and disable gssapi usage:

# needed for SASL_GSSAPI authentication:
try:
import gssapi
from gssapi.raw.misc import GSSError
except ImportError:
#no gssapi available, will disable gssapi mechanism
gssapi = None
GSSError = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants