Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

odfesql utility: could not run with Python 3.9 #168

Open
eduard-haritonov opened this issue Apr 27, 2021 · 0 comments
Open

odfesql utility: could not run with Python 3.9 #168

eduard-haritonov opened this issue Apr 27, 2021 · 0 comments

Comments

@eduard-haritonov
Copy link

Description of the issue

  • OS: Ubuntu 21.04

  • Python3 version: Python 3.9.4

  • odfesql has been successfully installed with the following command:
    $ pip3 install odfe-sql-cli

  • When odfesql was executed, it was terminated with error message:

    $ odfesql https://localhost:9200 --username admin --password admin
    Traceback (most recent call last):
      File "/home/hed/.local/bin/odfesql", line 5, in <module>
        from odfe_sql_cli.main import cli
      File "/home/hed/.local/lib/python3.9/site-packages/odfe_sql_cli/main.py", line 21, in <module>
        from .esconnection import ESConnection
      File "/home/hed/.local/lib/python3.9/site-packages/odfe_sql_cli/esconnection.py", line 22, in <module>
        from elasticsearch import Elasticsearch, RequestsHttpConnection
      File "/home/hed/.local/lib/python3.9/site-packages/elasticsearch/__init__.py", line 24, in <module>
        from .client import Elasticsearch
      File "/home/hed/.local/lib/python3.9/site-packages/elasticsearch/client/__init__.py", line 5, in <module>
        from ..transport import Transport
      File "/home/hed/.local/lib/python3.9/site-packages/elasticsearch/transport.py", line 5, in <module>
        from .connection import Urllib3HttpConnection
      File "/home/hed/.local/lib/python3.9/site-packages/elasticsearch/connection/__init__.py", line 2, in <module>
        from .http_requests import RequestsHttpConnection
      File "/home/hed/.local/lib/python3.9/site-packages/elasticsearch/connection/http_requests.py", line 3, in <module>
        from base64 import decodestring
    ImportError: cannot import name 'decodestring' from 'base64' (/usr/lib/python3.9/base64.py)
    

Workaround

The issue was fixed after modifying the following files:

  • ~/.local/lib/python3.9/site-packages/elasticsearch/connection/http_requests.py
  • ~/.local/lib/python3.9/site-packages/elasticsearch/connection/http_urllib3.py

In both files the line
from base64 import decodestring
was replaced with
from base64 import decodebytes

After these changes odfesql utility has been run successfully:

$ odfesql https://localhost:9200 --username admin --password admin
....
Server: Open Distro for ES 7.10.2
CLI Version: 1.13.0.0
Endpoint: https://localhost:9200
Query Language: sql
odfesql> 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant