1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Error of Could not reach host. Are you offline when converting html file into PDF

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I am attempting to change an html file into PDF document. I tried multiple methods but none of them proved effective. The html documentwas saved stored on the U drive of my company's network.

    For instance, when I am use pyhtml2pdf, I consistently encounter the error displayed below.

    https://pypi.org/project/pyhtml2pdf/

    from pyhtml2pdf import converter
    filepath_html='U:/Data/test.html'
    path = os.path.abspath(filepath_html)
    converter.convert(f'{path}', 'sample.pdf')


    714 # Make the request on the httplib connection object.
    --> 715 httplib_response = self._make_request(
    716 conn,
    717 method,
    718 url,
    719 timeout=timeout_obj,
    720 body=body,
    721 headers=headers,
    722 chunked=chunked,
    723 )
    725 # If we're going to release the connection in ``finally:``, then
    726 # the response doesn't need to know about the connection. Otherwise
    727 # it will also try to release it and we'll have a double-release
    728 # mess.

    File c:\ProgramData\anaconda_envs\dash3\Lib\site-packages\urllib3\connectionpool.py:404, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    403 try:
    --> 404 self._validate_conn(conn)
    405 except (SocketTimeout, BaseSSLError) as e:
    406 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

    File c:\ProgramData\anaconda_envs\dash3\Lib\site-packages\urllib3\connectionpool.py:1060, in HTTPSConnectionPool._validate_conn(self, conn)
    ...
    ---> 35 raise exceptions.ConnectionError(f"Could not reach host. Are you offline?")
    36 self.validate_response(resp)
    37 return resp

    ConnectionError: Could not reach host. Are you offline?

    Continue reading...

Compartilhe esta Página