pyw file runs fine, but after converting to exe getting "Unhandled exception in script" error

139 views
Skip to first unread message

Adi F.

unread,
Jul 30, 2023, 3:44:11 AM7/30/23
to PyInstaller
Hi. 

I have a script in Python that organizes files into folders based on a file and folder list in an Excel file.

Full disclosure: My Python and coding skills are pretty basic and I did get help from ChatGPT when creating this script

The script is working fine and I get no errors when I run the python file (pyw).

Now, I want this script to be accessible to anyone, regardless of whether they have Python installed or not, and regardless of Python version, so I'm encapsulating the script in an .exe file using PyInstaller.

When running the .exe created by PyInstaller - the script functions correctly and the results are as intended, but I get the following error message:

Unhandled exception in script

Failed to exectue script 'files_to_folders_per_excel_v2.2' due to unhandled exception: join() argument must be str, bytes, or os.PathLike object, not 'float'

Traceback (most recent call last):

File "files_to_folders_per_excel_v2.2.pyw", line 64, in <module>

File "ntpath.py", line 143, in join

File "genericpath.py", line 152, in _check_arg_types

TypeError: join() argument must be str, bytes, or os.PathLike object, not 'float'


Here's the Python code in github:

If anyone has any ideas how I can make the exe file run without any error messages, please let me know. Thanks!

Steve Barnes

unread,
Jul 30, 2023, 4:27:36 AM7/30/23
to pyins...@googlegroups.com

This problem can occur when the contents of row[folder_header] is of type float rather than string – e.g. if the value at that location is 1.0 then you will be trying to string join “some_path” and 1.0 which will not work. You should be able to resolve this by changing line 64 to read:

target_folder_path = os.path.join(organized_folder_path, str(target_folder_path))

Hope that helps.

 

Steve

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/f9c01e30-df36-4ca7-a429-ee9097bc5639n%40googlegroups.com.

Chris Barker

unread,
Aug 1, 2023, 2:18:49 AM8/1/23
to pyins...@googlegroups.com
key point -- this has nothing to do with PyInstaller -- it's an issue with your Python code -- perhaps it came up with a different input than you had tested on (testing things is hard!

On Sun, Jul 30, 2023 at 1:27 AM Steve Barnes <Gadge...@live.co.uk> wrote:

This problem can occur when the contents of row[folder_header] is of type float rather than string – e.g. if the value at that location is 1.0 then you will be trying to string join “some_path” and 1.0 which will not work. You should be able to resolve this by changing line 64 to read:

target_folder_path = os.path.join(organized_folder_path, str(target_folder_path))


However -- is the numeric value actually supposed to be a file / folder name? Or is that another bug? 

-CHB


 


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov
Reply all
Reply to author
Forward
0 new messages