Python + Couchbase + Docker basic example not working


FROM python:3.6
RUN apt-get update && apt-get install -y git-all python3-dev python3-pip python3-setuptools cmake build-essential libssl-dev
RUN pip install couchbase==3.1.1
CMD python

Python’s file

from import QueryIndexManager

if __name__ == "__main__":

Run command: docker build . -t couchbase_issue && docker run couchbase_issue

Error log:

Traceback (most recent call last):
  File "", line 1, in <module>
    from import QueryIndexManager
  File "/usr/local/lib/python3.6/site-packages/couchbase/management/", line 8, in <module>
    from couchbase_core._pyport import Protocol
ImportError: cannot import name 'Protocol'

Protocol is introduced in python 3.8 and your basic app is using 3.6. I have tested your example with 3.8, it’s printing the Start log.

I am using another library that has dependency on Python 3.6. Is there no way of making this work in 3.6?

Try with Couchbase SDK version that is compatible with python 3.6.

Porting to 3.8 worked, but I really hope that there is a better solution that can work with 3.6. Various ML/AI related libraries have either not ported to 3.8 completely, or broken backwards compatibility in doing so.

Hi @Gautam_Singhania – can you bash into the Docker container and do the following:

python -m pip uninstall typing-extensions
python -m pip install typing-extensions==

You should also be able to add RUN commands to your dockerfile.
The typing-extensions package made an update over the week which is causing this ImportError. This should be corrected in the 3.1.2 SDK release (happening soon).