Open Jancs-E opened 1 year ago
I’ll take a look. From the traceback, it’s trying to create the font mapping file and you don’t have permission to write to that dir. Try “run as administrator” or sudo. Once it’s created it shouldn’t have to create it again.
I would say that it is most incorrect solution of the problem - the fact that module is installed system-wide does not mean that the modules using it should be run with elevated user rights. May be the missing file should be generated at the install time?
Like I said - I’ll take a look. Maybe I can create the file during installation. I was giving you an avoidance procedure for now.
I am facing the exact same error in a different environment, namely a cloud function - on GCP, but should apply on any platform/provider preventing root access:
OSError: [Errno 30] Read-only file system: '/layers/google.python.pip/pip/lib/python3.11/site-packages/xls2xlsx/fontnames.yaml'
@snoopyjc I can have a look as it may just be a matter of redirecting to a temp dir or file.
I think what needs to be done is this file needs to be created during the installation process, not when the program is first run
Actually it's at runtime that
to_xlsx
instantiates FontUtils()
, fontnames.yml
if exists, or parses the environment to gather fonts details, The culprit is https://github.com/snoopyjc/xls2xlsx/blob/642f980cd543cab0217e0d63e0e2568987c4ea90/xls2xlsx/htmlxls2xlsx.py#L52 as one can usually not save/edit in the site packages... unless run locally as admin as you suggested.
I suggest using tempfile.gettempdir() to store the file as it is stable i.e. read or written from same place between calls. As per the specs, using the working dir is only as last resort.
trying to convert xls to xlsx I get error:
File "script.py", line XXX, in
x2x.to_xlsx("output.xlsx")
File "/usr/lib64/python3.9/site-packages/xls2xlsx/xls2xlsx.py", line 190, in to_xlsx return self.h2x.to_xlsx(filename=filename) File "/usr/lib64/python3.9/site-packages/xls2xlsx/htmlxls2xlsx.py", line 1017, in to_xlsx font_utils = FontUtils() File "/usr/lib64/python3.9/site-packages/xls2xlsx/htmlxls2xlsx.py", line 102, in init with open(fontnames_file, 'w') as fn: PermissionError: [Errno 13] Permission denied: '/usr/lib64/python3.9/site-packages/xls2xlsx/fontnames.yaml'
Its correct as such file doe not exist in the directory /usr/lib64/python3.9/site-packages/xls2xlsx/ Installation of the module went w/o errors