ImportError: cannot import name ‘decodestring’ from ‘base64’ (/usr/lib64/python3.9/base64.py)

can you help me to fix bug that says

    Traceback (most recent call last):
      File "/home/fofive/PycharmProjects/pythonProject/main.py", line 1, in <module>
        from elasticsearch import Elasticsearch, RequestsHttpConnection
      File "/usr/local/lib/python3.9/dist-packages/elasticsearch/__init__.py", line 24, in <module>
        from .client import Elasticsearch
      File "/usr/local/lib/python3.9/dist-packages/elasticsearch/client/__init__.py", line 4, in <module>
        from ..transport import Transport
      File "/usr/local/lib/python3.9/dist-packages/elasticsearch/transport.py", line 5, in <module>
        from .connection import Urllib3HttpConnection
      File "/usr/local/lib/python3.9/dist-packages/elasticsearch/connection/__init__.py", line 2, in <module>
        from .http_requests import RequestsHttpConnection
      File "/usr/local/lib/python3.9/dist-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)

    Process finished with exit code 1

when I’m trying to import elasticsearch 7.10.1 to python 3.9 on kali linux PyCharm Community

Welcome to our community! :smiley:

What does your code look like?

Glad to find feedback I really need in :slight_smile:
It happends with no matter wich code is in. All begins when I try import next modules:

from elasticsearch import Elasticsearch, RequestsHttpConnection
print('Hello, World!')

Maybe will be helpfull to note next notification I get when I boot PyCharm Community on, but it's pretty common issue most of my projects are not conflict with, so I do believe Elasticsearch don't mess with _JAVA_OPTIONS variable neither:Screenshot from 2021-01-27 15-35-15

Another reason I think it definitely was not IDE variables is because same problem comes up on GuitHub almost a year ago with some browser-support python IDE, that use site-packages instead of dist-packages like Conda. There is no answer as well: https://github.com/Hironsan/bertsearch/issues/27

As I can guess problem is caused by the version of base64 module I am running, while the version of elasticsearch I installed dependent on a different version of base64 module. But I'm pretty sure I have last versions of both.

So am I suppose to downgrade something? I tried to let it go on different interpreters of python, and the only difference I got after using python bellow 3.9 is the output that elasticsearch module does not installed for such a low version. While in python 3.9 I have the output that base 64 undecodeble.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.