Search code examples
pythonurlbeautifulsoupurllibcx-freeze

An unexpected URLError is raised when I run my compiled Python script


I've been working on a web scraping program. It works fine when I run it in the Pycharm IDE. However, when compiled with cx_Freeze, I get the error:

urllib.error.URLError: <urlopen error unknown url type: https>

Here is the part of my code that concerns the url processing:

url = f"https://op.gg/summoner/userName={f_username}"
        page_html = urlopen(url)
        page_content = BeautifulSoup(page_html, features="html.parser")

I've searched the internet and I've found that the error may be due to a single-quote somewhere. However:

  • I can run it in an IDE
  • When I print my url, it is perfectly fine (no single-quote).

Any help is appreciated. Thanks!


Solution

  • The error message says : "unknown url type: https", so the problem is that HTTPS is not supported.

    https://docs.python.org/3/library/http.client.html says : "HTTPS support is only available if Python was compiled with SSL support (through the ssl module)."