Pyinstaller: AssertionError: Failed to determine matplotlib's data directory!

466 views
Skip to first unread message

T K

unread,
Aug 7, 2022, 1:10:32 PM8/7/22
to PyInstaller
Hi,

I am new to programming in Python. I am learning programming to automate various tasks at my job - I work as portfolio manager in the finance industry. I recently created a script that pulls in a csv into pandas, manipulates it, spits out cleaned data for human review, and moves a few files around to archive previously run batches. We have two employees that do not have any Python version installed on their machines, so I wanted to use Pyinstaller to create and .exe for them to use. When I run Pyinstaller on my script (no options) the below Traceback shows up. I've Googled as much as I can to try and fix it, but to no avail. With my competence level, most of the traceback makes little sense, so I figured I should reach out directly to Pyinstaller. Please let me know if I need to do something different in asking for help. I want to learn. Thank you!

\\PyInstaller\\hooks'...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 876, in <module>
    rcParamsDefault = _rc_params_in_file(
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 778, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "C:\Users\TylerKarl\anaconda3\lib\contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 751, in _open_file_or_url
    fname = os.path.expanduser(fname)
  File "C:\Users\TylerKarl\anaconda3\lib\ntpath.py", line 293, in expanduser
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not WindowsPath
119124 INFO: Loading module hook 'hook-matplotlib.py' from 'C:\\Users\\TylerKarl\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 876, in <module>
    rcParamsDefault = _rc_params_in_file(
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 778, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "C:\Users\TylerKarl\anaconda3\lib\contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\matplotlib\__init__.py", line 751, in _open_file_or_url
    fname = os.path.expanduser(fname)
  File "C:\Users\TylerKarl\anaconda3\lib\ntpath.py", line 293, in expanduser
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not WindowsPath
Traceback (most recent call last):
  File "C:\Users\TylerKarl\anaconda3\Scripts\pyinstaller-script.py", line 10, in <module>
    sys.exit(run())
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 124, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 58, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 793, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 725, in build
    exec(code, spec_namespace)
  File "C:\Users\TylerKarl\Juncture Wealth\Juncture Wealth Strategies - Company\Programming\Python\Cash Balances Scrub\cash_balance_scrub.spec", line 7, in <module>
    a = Analysis(['cash_balance_scrub.py'],
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 277, in __init__
    self.__postinit__()
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 155, in __postinit__
    self.assemble()
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 445, in assemble
    self.graph.process_post_graph_hooks(self)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 326, in process_post_graph_hooks
    module_hook.post_graph(analysis)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 398, in post_graph
    self._load_hook_module()
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 361, in _load_hook_module
    self._hook_module = importlib_load_source(self.hook_module_name, self.hook_filename)
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\compat.py", line 606, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 529, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 1029, in load_module
  File "<frozen importlib._bootstrap_external>", line 854, in load_module
  File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\TylerKarl\anaconda3\lib\site-packages\PyInstaller\hooks\hook-matplotlib.py", line 15, in <module>
    assert mpl_data_dir, "Failed to determine matplotlib's data directory!"
AssertionError: Failed to determine matplotlib's data directory!
Reply all
Reply to author
Forward
0 new messages