ERROR: for odoo-13-docker-compose_odoo13_1 a bytes-like object is required, not 'str' in docker-compose up

I have stumbled an error on my terminal regarding odoo installation via docker.

$ docker - compose up

odoo-13-docker-compose_db_1 is up-to-date

Starting odoo-13-docker-compose_odoo13_1 …

ERROR: for odoo-13-docker-compose_odoo13_1 a bytes-like object is required, not ‘str’

ERROR: for odoo13 a bytes-like object is required, not ‘str’

Traceback (most recent call last):

File “/usr/lib/python3/dist-packages/docker/api/client.py”, line 261, in _raise_for_status

response.raise_for_status()

File “/usr/lib/python3/dist-packages/requests/models.py”, line 940, in raise_for_status

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.22/containers/349ba7cac8d4be0b9ade1a3dc7a03c5dd4323552068dd0af2a5f4a04e010dd0e/start

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/lib/python3/dist-packages/compose/service.py”, line 625, in start_container

container.start()

File “/usr/lib/python3/dist-packages/compose/container.py”, line 241, in start

return self.client.start(self.id, **options)

File “/usr/lib/python3/dist-packages/docker/utils/decorators.py”, line 19, in wrapped

return f(self, resource_id, *args, **kwargs)

File “/usr/lib/python3/dist-packages/docker/api/container.py”, line 1095, in start

self._raise_for_status(res)

File “/usr/lib/python3/dist-packages/docker/api/client.py”, line 263, in _raise_for_status

raise create_api_error_from_http_exception(e)

File “/usr/lib/python3/dist-packages/docker/errors.py”, line 31, in create_api_error_from_http_exception

raise cls(e, response=response, explanation=explanation)

docker.errors.APIError: 500 Server Error: Internal Server Error (“b’driver failed programming external connectivity on endpoint odoo-13-docker-compose_odoo13_1 (b47b736966bdeb7583e8a4285bb118fb6c82e63d4c0de977e612d7a9686c88fd): Bind for 0.0.0.0:10013 failed: port is already allocated’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/bin/docker-compose”, line 11, in

load_entry_point('docker-compose==1.25.0', 'console_scripts', 'docker-compose')()

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 72, in main

command()

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 128, in perform_command

handler(command, command_options)

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 1107, in up

to_attach = up(False)

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 1088, in up

return self.project.up(

File “/usr/lib/python3/dist-packages/compose/project.py”, line 565, in up

results, errors = parallel.parallel_execute(

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 112, in parallel_execute

raise error_to_reraise

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 210, in producer

result = func(obj)

File “/usr/lib/python3/dist-packages/compose/project.py”, line 548, in do

return service.execute_convergence_plan(

File “/usr/lib/python3/dist-packages/compose/service.py”, line 567, in execute_convergence_plan

return self._execute_convergence_start(

File “/usr/lib/python3/dist-packages/compose/service.py”, line 506, in _execute_convergence_start

_, errors = parallel_execute(

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 112, in parallel_execute

raise error_to_reraise

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 210, in producer

result = func(obj)

File “/usr/lib/python3/dist-packages/compose/service.py”, line 508, in

lambda c: self.start_container_if_stopped(c, attach_logs=not detached, quiet=True),

File “/usr/lib/python3/dist-packages/compose/service.py”, line 620, in start_container_if_stopped

return self.start_container(container)

File “/usr/lib/python3/dist-packages/compose/service.py”, line 627, in start_container

if "driver failed programming external connectivity" in ex.explanation:

TypeError: a bytes-like object is required, not ‘str’

Error in sys.excepthook:

Traceback (most recent call last):

File “/usr/lib/python3/dist-packages/apport_python_hook.py”, line 153, in apport_excepthook

with os.fdopen(os.open(pr_filename,

FileNotFoundError: [Errno 2] No such file or directory: ‘/var/crash/_usr_bin_docker-compose.1000.crash’

Original exception was:

Traceback (most recent call last):

File “/usr/lib/python3/dist-packages/docker/api/client.py”, line 261, in _raise_for_status

response.raise_for_status()

File “/usr/lib/python3/dist-packages/requests/models.py”, line 940, in raise_for_status

raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http+docker://localhost/v1.22/containers/349ba7cac8d4be0b9ade1a3dc7a03c5dd4323552068dd0af2a5f4a04e010dd0e/start

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/lib/python3/dist-packages/compose/service.py”, line 625, in start_container

container.start()

File “/usr/lib/python3/dist-packages/compose/container.py”, line 241, in start

return self.client.start(self.id, **options)

File “/usr/lib/python3/dist-packages/docker/utils/decorators.py”, line 19, in wrapped

return f(self, resource_id, *args, **kwargs)

File “/usr/lib/python3/dist-packages/docker/api/container.py”, line 1095, in start

self._raise_for_status(res)

File “/usr/lib/python3/dist-packages/docker/api/client.py”, line 263, in _raise_for_status

raise create_api_error_from_http_exception(e)

File “/usr/lib/python3/dist-packages/docker/errors.py”, line 31, in create_api_error_from_http_exception

raise cls(e, response=response, explanation=explanation)

docker.errors.APIError: 500 Server Error: Internal Server Error (“b’driver failed programming external connectivity on endpoint odoo-13-docker-compose_odoo13_1 (b47b736966bdeb7583e8a4285bb118fb6c82e63d4c0de977e612d7a9686c88fd): Bind for 0.0.0.0:10013 failed: port is already allocated’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/usr/bin/docker-compose”, line 11, in

load_entry_point('docker-compose==1.25.0', 'console_scripts', 'docker-compose')()

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 72, in main

command()

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 128, in perform_command

handler(command, command_options)

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 1107, in up

to_attach = up(False)

File “/usr/lib/python3/dist-packages/compose/cli/main.py”, line 1088, in up

return self.project.up(

File “/usr/lib/python3/dist-packages/compose/project.py”, line 565, in up

results, errors = parallel.parallel_execute(

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 112, in parallel_execute

raise error_to_reraise

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 210, in producer

result = func(obj)

File “/usr/lib/python3/dist-packages/compose/project.py”, line 548, in do

return service.execute_convergence_plan(

File “/usr/lib/python3/dist-packages/compose/service.py”, line 567, in execute_convergence_plan

return self._execute_convergence_start(

File “/usr/lib/python3/dist-packages/compose/service.py”, line 506, in _execute_convergence_start

_, errors = parallel_execute(

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 112, in parallel_execute

raise error_to_reraise

File “/usr/lib/python3/dist-packages/compose/parallel.py”, line 210, in producer

result = func(obj)

File “/usr/lib/python3/dist-packages/compose/service.py”, line 508, in

lambda c: self.start_container_if_stopped(c, attach_logs=not detached, quiet=True),

File “/usr/lib/python3/dist-packages/compose/service.py”, line 620, in start_container_if_stopped

return self.start_container(container)

File “/usr/lib/python3/dist-packages/compose/service.py”, line 627, in start_container

if "driver failed programming external connectivity" in ex.explanation:

TypeError: a bytes-like object is required, not ‘str’

Has anyone had any solution to this?

This is, I believe, a Python¹ problem with type conversions. The problem here is (among other things, possibly) the habit of many programmers to handle common problems and errors as exceptions bubbling through all the function calls instead of treating them as something that can happen and should be dealt with where they occur.

According to Odoo’s website, you should probably install the Python module “num2words” with
sudo pip3 install num2words.

However, if you plan to run such a highly complex piece of enterprise software, you should probably contact their support.

¹I don’t understand why everybody insists on using fucking Python for everything. I get it, if you want to use fancy Qt-interfaces or well-established libraries like TensorFlow, it makes total sense, but its libraries and versions model is a nightmare when it comes to run e.g. installation scripts. A good programming language should make simple things simple and difficult things possible.

1 Like

Have nothing to add. Nuff said.

Or maybe I do:

I would recommend the following language to every hardcore Python developer:

It’s like Python, but better.

1 Like

Oh no, more to learn … poor head.

PS: I’ve never heard of it but seems interesting.

1 Like

The reason for this error is that in Python 3, strings are Unicode, but when transmitting on the network, the data needs to be bytes instead. We can convert bytes to string using bytes class decode() instance method, So you need to decode the bytes object to produce a string. In Python 3 , the default encoding is “utf-8” , so you can use directly:

b"python byte to string".decode("utf-8")

Python makes a clear distinction between bytes and strings . Bytes objects contain raw data — a sequence of octets — whereas strings are Unicode sequences . Conversion between these two types is explicit: you encode a string to get bytes, specifying an encoding (which defaults to UTF-8); and you decode bytes to get a string. Clients of these functions should be aware that such conversions may fail, and should consider how failures are handled.