D
D
duffy_omg2020-09-13 20:50:09
Python
duffy_omg, 2020-09-13 20:50:09

Why does the path change after using Pyinstaller?

I specify the path to the win32com excel library COM via __gen_path__ in __init__.py

__gen_path__ = 'C:\\Users\\kfd23\\Desktop\\Excel\\RX\\gen_py\\3.7'

Before compiling the file to exe, the path looks like this:
print(win32com.__gen_path__)
C:\Users\kfd23\Desktop\Excel\RX\gen_py\3.7
In this case, the code works well, everything is in order.
After compiling the file to exe via pyinstaller, the path changes to:
C:\Users\kfd23\AppData\Local\Temp\tmpg63kwlo3\gen_py

As a result it gives an error
Traceback (most recent call last):
  File "new_proba_importa.py", line 14, in <module>
  File "win32com\client\__init__.py", line 178, in __getattr__
AttributeError: xlXYScatterLinesNoMarkers
[10228] Failed to execute script new_proba_importa

Because the path to COM objects changes and it throws an AttributeError error.
Why is the path to the COM library lost and can it be changed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question