We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: module 'faker.providers' has no attribute '__file__'
I converted my python code to .exe using cx_Freeze. While opening my .exe file I am getting this error.

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Program Files\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "DataGenerator.py", line 7, in <module>
  File "C:\Program Files\Python36\lib\site-packages\faker\__init__.py", line 4, in <module>
    from faker.factory import Factory
  File "C:\Program Files\Python36\lib\site-packages\faker\factory.py", line 10, in <module>
    from faker.config import DEFAULT_LOCALE, PROVIDERS, AVAILABLE_LOCALES
  File "C:\Program Files\Python36\lib\site-packages\faker\config.py", line 11, in <module>
    PROVIDERS = find_available_providers([import_module(path) for path in META_PROVIDERS_MODULES])
  File "C:\Program Files\Python36\lib\site-packages\faker\utils\loading.py", line 29, in find_available_providers
    providers = ['.'.join([providers_mod.__package__, mod]) for mod in list_module(providers_mod)]
  File "C:\Program Files\Python36\lib\site-packages\faker\utils\loading.py", line 7, in list_module
    path = os.path.dirname(module.__file__)
AttributeError: module 'faker.providers' has no attribute '__file__'

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `faker/utils/loading.py`
Content:
```
1 import os
2 import sys
3 from importlib import import_module
4 import pkgutil
5 
6 
7 def get_path(module):
8     if getattr(sys, 'frozen', False):
9         # frozen
10         path = os.path.dirname(sys.executable)
11     else:
12         # unfrozen
13         path = os.path.dirname(os.path.realpath(module.__file__))
14     return path
15 
16 
17 def list_module(module):
18     path = get_path(module)
19     modules = [name for finder, name,
20                is_pkg in pkgutil.iter_modules([path]) if is_pkg]
21     return modules
22 
23 
24 def find_available_locales(providers):
25     available_locales = set()
26 
27     for provider_path in providers:
28 
29         provider_module = import_module(provider_path)
30         if getattr(provider_module, 'localized', False):
31             langs = list_module(provider_module)
32             available_locales.update(langs)
33     return available_locales
34 
35 
36 def find_available_providers(modules):
37     available_providers = set()
38     for providers_mod in modules:
39         providers = [
40             '.'.join([providers_mod.__package__, mod])
41             for mod in list_module(providers_mod) if mod != '__pycache__'
42         ]
43         available_providers.update(providers)
44     return sorted(available_providers)
45
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/faker/utils/loading.py b/faker/utils/loading.py
--- a/faker/utils/loading.py
+++ b/faker/utils/loading.py
@@ -7,7 +7,10 @@
 def get_path(module):
     if getattr(sys, 'frozen', False):
         # frozen
-        path = os.path.dirname(sys.executable)
+        base_dir = os.path.dirname(sys.executable)
+        lib_dir = os.path.join(base_dir, "lib")
+        module_to_rel_path = os.path.join(*module.__package__.split("."))
+        path = os.path.join(lib_dir, module_to_rel_path)
     else:
         # unfrozen
         path = os.path.dirname(os.path.realpath(module.__file__))

{"golden_diff": "diff --git a/faker/utils/loading.py b/faker/utils/loading.py\n--- a/faker/utils/loading.py\n+++ b/faker/utils/loading.py\n@@ -7,7 +7,10 @@\n def get_path(module):\n     if getattr(sys, 'frozen', False):\n         # frozen\n-        path = os.path.dirname(sys.executable)\n+        base_dir = os.path.dirname(sys.executable)\n+        lib_dir = os.path.join(base_dir, \"lib\")\n+        module_to_rel_path = os.path.join(*module.__package__.split(\".\"))\n+        path = os.path.join(lib_dir, module_to_rel_path)\n     else:\n         # unfrozen\n         path = os.path.dirname(os.path.realpath(module.__file__))\n", "issue": "AttributeError: module 'faker.providers' has no attribute '__file__'\nI converted my python code to .exe using cx_Freeze. While opening my .exe file I am getting this error.\r\n\r\nTraceback (most recent call last):\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\cx_Freeze\\initscripts\\__startup__.py\", line 14, in run\r\n    module.run()\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\cx_Freeze\\initscripts\\Console.py\", line 26, in run\r\n    exec(code, m.__dict__)\r\n  File \"DataGenerator.py\", line 7, in <module>\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\faker\\__init__.py\", line 4, in <module>\r\n    from faker.factory import Factory\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\faker\\factory.py\", line 10, in <module>\r\n    from faker.config import DEFAULT_LOCALE, PROVIDERS, AVAILABLE_LOCALES\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\faker\\config.py\", line 11, in <module>\r\n    PROVIDERS = find_available_providers([import_module(path) for path in META_PROVIDERS_MODULES])\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\faker\\utils\\loading.py\", line 29, in find_available_providers\r\n    providers = ['.'.join([providers_mod.__package__, mod]) for mod in list_module(providers_mod)]\r\n  File \"C:\\Program Files\\Python36\\lib\\site-packages\\faker\\utils\\loading.py\", line 7, in list_module\r\n    path = os.path.dirname(module.__file__)\r\nAttributeError: module 'faker.providers' has no attribute '__file__'\n", "before_files": [{"content": "import os\nimport sys\nfrom importlib import import_module\nimport pkgutil\n\n\ndef get_path(module):\n    if getattr(sys, 'frozen', False):\n        # frozen\n        path = os.path.dirname(sys.executable)\n    else:\n        # unfrozen\n        path = os.path.dirname(os.path.realpath(module.__file__))\n    return path\n\n\ndef list_module(module):\n    path = get_path(module)\n    modules = [name for finder, name,\n               is_pkg in pkgutil.iter_modules([path]) if is_pkg]\n    return modules\n\n\ndef find_available_locales(providers):\n    available_locales = set()\n\n    for provider_path in providers:\n\n        provider_module = import_module(provider_path)\n        if getattr(provider_module, 'localized', False):\n            langs = list_module(provider_module)\n            available_locales.update(langs)\n    return available_locales\n\n\ndef find_available_providers(modules):\n    available_providers = set()\n    for providers_mod in modules:\n        providers = [\n            '.'.join([providers_mod.__package__, mod])\n            for mod in list_module(providers_mod) if mod != '__pycache__'\n        ]\n        available_providers.update(providers)\n    return sorted(available_providers)\n", "path": "faker/utils/loading.py"}], "after_files": [{"content": "import os\nimport sys\nfrom importlib import import_module\nimport pkgutil\n\n\ndef get_path(module):\n    if getattr(sys, 'frozen', False):\n        # frozen\n        base_dir = os.path.dirname(sys.executable)\n        lib_dir = os.path.join(base_dir, \"lib\")\n        module_to_rel_path = os.path.join(*module.__package__.split(\".\"))\n        path = os.path.join(lib_dir, module_to_rel_path)\n    else:\n        # unfrozen\n        path = os.path.dirname(os.path.realpath(module.__file__))\n    return path\n\n\ndef list_module(module):\n    path = get_path(module)\n    modules = [name for finder, name,\n               is_pkg in pkgutil.iter_modules([path]) if is_pkg]\n    return modules\n\n\ndef find_available_locales(providers):\n    available_locales = set()\n\n    for provider_path in providers:\n\n        provider_module = import_module(provider_path)\n        if getattr(provider_module, 'localized', False):\n            langs = list_module(provider_module)\n            available_locales.update(langs)\n    return available_locales\n\n\ndef find_available_providers(modules):\n    available_providers = set()\n    for providers_mod in modules:\n        providers = [\n            '.'.join([providers_mod.__package__, mod])\n            for mod in list_module(providers_mod) if mod != '__pycache__'\n        ]\n        available_providers.update(providers)\n    return sorted(available_providers)\n", "path": "faker/utils/loading.py"}]}