'Why doesn't os.makedirs work when bundling python script with pyinstaller?

I made a script in Python (v.3.9.7) that creates some folders at a certain point. When I run the .py file in Pycharm it works fine but when I run the .exe file created with pyinstaller (regardless whether the '--onefile' option is on/off) the code seems to work (the progress bars from the tqdm package show up) but the folders are not created.

Does anyone know why?

Here the MWE:

import os
from tqdm import tqdm

def set_variables(web_root, authors):
    abspath = os.path.abspath(__file__)
    parent_dir = os.path.dirname(abspath)
    os.chdir(parent_dir)
    user_input_urls = [web_root + elem + '/' for elem in authors]

    return parent_dir, user_input_urls


def main():
    web_root = 'https://albalearning.com/audiolibros/'
    authors = ['benedetti', 'benavente', 'hesse']  # author list manually defined
    parent_dir, user_input_urls = set_variables(web_root, authors)
    for url in tqdm(user_input_urls, position=0, desc='url', leave=True,
                    colour='green', ncols=80):
        folder = authors[user_input_urls.index(url)]
        file_path = os.path.join(parent_dir, folder)
        os.makedirs(file_path, exist_ok=True)
    return None


if __name__ == '__main__':
    main()

There is a warning file created in the 'build' folder with messages on missing packages. However, I don't see any problem with the 'os' package anywhere.

Warning messages:

missing module named 'typing.io' - imported by importlib.resources (top-level)
missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed, optional), subprocess (optional)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), pathlib (delayed, conditional, optional), subprocess (optional), http.server (delayed, optional), webbrowser (delayed), netrc (delayed, conditional), getpass (delayed), distutils.util (delayed, conditional, optional)
missing module named _posixsubprocess - imported by subprocess (optional), multiprocessing.util (delayed)
missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named _posixshmem - imported by multiprocessing.resource_tracker (conditional), multiprocessing.shared_memory (conditional)
missing module named multiprocessing.set_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_start_method - imported by multiprocessing (top-level), multiprocessing.spawn (top-level)
missing module named multiprocessing.get_context - imported by multiprocessing (top-level), multiprocessing.pool (top-level), multiprocessing.managers (top-level), multiprocessing.sharedctypes (top-level)
missing module named multiprocessing.TimeoutError - imported by multiprocessing (top-level), multiprocessing.pool (top-level)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named termios - imported by tty (top-level), getpass (optional), tqdm.utils (delayed, optional)
missing module named 'java.lang' - imported by platform (delayed, optional), xml.sax._exceptions (conditional)
missing module named multiprocessing.BufferTooShort - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.AuthenticationError - imported by multiprocessing (top-level), multiprocessing.connection (top-level)
missing module named multiprocessing.RLock - imported by multiprocessing (delayed, conditional, optional), tqdm.std (delayed, conditional, optional)
missing module named asyncio.DefaultEventLoopPolicy - imported by asyncio (delayed, conditional), asyncio.events (delayed, conditional)
missing module named vms_lib - imported by platform (delayed, optional)
missing module named java - imported by platform (delayed)
missing module named _winreg - imported by platform (delayed, optional)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional)
missing module named org - imported by pickle (optional)
missing module named posix - imported by os (conditional, optional), shutil (conditional), importlib._bootstrap_external (conditional)
missing module named resource - imported by posix (top-level), test.support (delayed, conditional, optional)
missing module named pep517 - imported by importlib.metadata (delayed)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), zipimport (top-level)
missing module named pyimod03_importers - imported by C:\Users\dende\Documents\Audiolibros\Auto_extraction\auto_extract\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (top-level)
missing module named 'IPython.display' - imported by tqdm.notebook (conditional, optional)
missing module named 'IPython.html' - imported by tqdm.notebook (conditional, optional)
missing module named IPython - imported by tqdm.notebook (conditional, optional)
missing module named ipywidgets - imported by tqdm.notebook (conditional, optional)
missing module named fcntl - imported by tqdm.utils (delayed, optional)
missing module named setuptools_scm - imported by tqdm.version (optional)
missing module named 'pandas.core' - imported by tqdm.std (delayed, optional)
missing module named pandas - imported by tqdm.std (delayed, optional)
missing module named 'matplotlib.pyplot' - imported by tqdm.gui (delayed)
missing module named matplotlib - imported by tqdm.gui (delayed)
missing module named importlib_resources - imported by tqdm.cli (delayed, conditional, optional)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source