win32com.client Issues

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

win32com.client Issues

Ben Crews
Hello. I have a script which utilizes the win32com.client module and takes input from a spreadsheet to generate multiple word documents based on a standard template. This all works just fine in my dev environment, and with certain installations on other machines. When I try to package up the whole system, i've been running the basic pyinstaller myscript.py command. After it's packaged, I move the input and template files to the same directory as the exe, and some parts still work.

It seems like the Workbooks.Worksheets.Range() method doesn't work after I've packaged up. My code will register the win32com application object, and open up the input file. It will even read the data (I can see it output with logging statements), but when it gets to a line defining a range, it just stops.

logging.debug(startCell.Address) #Reports correct value in the log
logging.debug(endCell.Address)   #Reports correct value in the log
workingRange
= InputSheet.Range(startCell, endCell).Value
logging.info(workingRange)
InputBook.Save()
InputBook.Close()

Through trial and error I've found that if I remove the "Value" the script will continue on to save and close the workbook, but will not log the data. I'm truly stumped, and I just don't get this error when running without pyinstaller.


I can't share the full code without authorization from my company, but does any of this sound familiar?


Thanks,

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: win32com.client Issues

Marx
Hi,
Please try out this solution if it can help you .
complete details are there.

On Sat, Apr 27, 2019 at 1:03 PM Ben Crews <[hidden email]> wrote:
Hello. I have a script which utilizes the win32com.client module and takes input from a spreadsheet to generate multiple word documents based on a standard template. This all works just fine in my dev environment, and with certain installations on other machines. When I try to package up the whole system, i've been running the basic pyinstaller myscript.py command. After it's packaged, I move the input and template files to the same directory as the exe, and some parts still work.

It seems like the Workbooks.Worksheets.Range() method doesn't work after I've packaged up. My code will register the win32com application object, and open up the input file. It will even read the data (I can see it output with logging statements), but when it gets to a line defining a range, it just stops.

logging.debug(startCell.Address) #Reports correct value in the log
logging.debug(endCell.Address)   #Reports correct value in the log
workingRange
= InputSheet.Range(startCell, endCell).Value
logging.info(workingRange)
InputBook.Save()
InputBook.Close()

Through trial and error I've found that if I remove the "Value" the script will continue on to save and close the workbook, but will not log the data. I'm truly stumped, and I just don't get this error when running without pyinstaller.


I can't share the full code without authorization from my company, but does any of this sound familiar?


Thanks,

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


--
Regards,
Marx Chidambara Babu M.B

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: win32com.client Issues

Elliot Garbus

Are you doing a single file build or a directory build?  You need to tell Pyinstaller where the files are located. Read the section in the docs on runtime information.

 

https://pyinstaller.readthedocs.io/en/stable/runtime-information.html

 

When your program is not frozen, the standard Python variable __file__ is the full path to the script now executing. When a bundled app starts up, the bootloader sets the sys.frozen attribute and stores the absolute path to the bundle folder in sys._MEIPASS. For a one-folder bundle, this is the path to that folder, wherever the user may have put it. For a one-file bundle, this is the path to the _MEIxxxxxx temporary folder created by the bootloader 

 

From: [hidden email]
Sent: Friday, May 3, 2019 12:54 AM
To: [hidden email]
Subject: Re: [PyInstaller] win32com.client Issues

 

Hi,

Please try out this solution if it can help you .

complete details are there.

 

On Sat, Apr 27, 2019 at 1:03 PM Ben Crews <[hidden email]> wrote:

Hello. I have a script which utilizes the win32com.client module and takes input from a spreadsheet to generate multiple word documents based on a standard template. This all works just fine in my dev environment, and with certain installations on other machines. When I try to package up the whole system, i've been running the basic pyinstaller myscript.py command. After it's packaged, I move the input and template files to the same directory as the exe, and some parts still work.

 

It seems like the Workbooks.Worksheets.Range() method doesn't work after I've packaged up. My code will register the win32com application object, and open up the input file. It will even read the data (I can see it output with logging statements), but when it gets to a line defining a range, it just stops.

 

logging.debug(startCell.Address) #Reports correct value in the log

logging.debug(endCell.Address)   #Reports correct value in the log

workingRange = InputSheet.Range(startCell, endCell).Value
logging
.info(workingRange)

InputBook.Save()

InputBook.Close()


Through trial and error I've found that if I remove the "Value" the script will continue on to save and close the workbook, but will not log the data. I'm truly stumped, and I just don't get this error when running without pyinstaller.

 

 

I can't share the full code without authorization from my company, but does any of this sound familiar?

 

 

Thanks,

 

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


 

--

Regards,
Marx Chidambara Babu M.B

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: win32com.client Issues

Ben Crews
I am building a single directory. Oddly enough, I haven't been including the files in the .spec as data. I've just been dropping them into the directory afterwards. When I add them in the spec and rebuild, my script doesn't get past the initial logging messages. In the build warnings, i'm seeing a top-level warning that it could not include the win32com.genpy module. Not sure if that's related...

Since I'm building a one-folder bundle, my file locations should be correct with the pyinstaller defaults, no?


Regards,

Ben

On Sat, May 4, 2019 at 5:35 AM Elliot Garbus <[hidden email]> wrote:

Are you doing a single file build or a directory build?  You need to tell Pyinstaller where the files are located. Read the section in the docs on runtime information.

 

https://pyinstaller.readthedocs.io/en/stable/runtime-information.html

 

When your program is not frozen, the standard Python variable __file__ is the full path to the script now executing. When a bundled app starts up, the bootloader sets the sys.frozen attribute and stores the absolute path to the bundle folder in sys._MEIPASS. For a one-folder bundle, this is the path to that folder, wherever the user may have put it. For a one-file bundle, this is the path to the _MEIxxxxxx temporary folder created by the bootloader 

 

From: [hidden email]
Sent: Friday, May 3, 2019 12:54 AM
To: [hidden email]
Subject: Re: [PyInstaller] win32com.client Issues

 

Hi,

Please try out this solution if it can help you .

complete details are there.

 

On Sat, Apr 27, 2019 at 1:03 PM Ben Crews <[hidden email]> wrote:

Hello. I have a script which utilizes the win32com.client module and takes input from a spreadsheet to generate multiple word documents based on a standard template. This all works just fine in my dev environment, and with certain installations on other machines. When I try to package up the whole system, i've been running the basic pyinstaller myscript.py command. After it's packaged, I move the input and template files to the same directory as the exe, and some parts still work.

 

It seems like the Workbooks.Worksheets.Range() method doesn't work after I've packaged up. My code will register the win32com application object, and open up the input file. It will even read the data (I can see it output with logging statements), but when it gets to a line defining a range, it just stops.

 

logging.debug(startCell.Address) #Reports correct value in the log

logging.debug(endCell.Address)   #Reports correct value in the log

workingRange = InputSheet.Range(startCell, endCell).Value
logging
.info(workingRange)

InputBook.Save()

InputBook.Close()


Through trial and error I've found that if I remove the "Value" the script will continue on to save and close the workbook, but will not log the data. I'm truly stumped, and I just don't get this error when running without pyinstaller.

 

 

I can't share the full code without authorization from my company, but does any of this sound familiar?

 

 

Thanks,

 

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


 

--

Regards,
Marx Chidambara Babu M.B

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


--
-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CAKS55pDsbYSWfa7b6euMzJp02g7M4MTjL-xv7hwOQSDo2YQdLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

RE: win32com.client Issues

Elliot Garbus

Here is a sample .spec file I’m using for a Wndows10 build.  Pyinstaller needs to be able to see and place your files for proper operation.  I strictly followed the directions on the Kivy site, and then built from there adding files to fix errors, and adding exclusions.  I’m far from an expert at pyinstaller, but happy to help as I can.

 

# -*- mode: python -*-
from kivy.deps import sdl2, glew
block_cipher = None

a = Analysis(['..\\main.py'],
             pathex=['..\\EnzoEditdist', 'C:\\Windows\\SysWOW64\\downlevel\\'],
             binaries=[],
             datas=[],
             hiddenimports=['win32timezone'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='EnzoEdit',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=False,
          console=False,
          icon='..\\enzo_e_icon.ico')
coll = COLLECT(exe, Tree('..\\', excludes=['.git', 'screenshots', 'EnzoEditDist','__pycache__','.idea','*.bat']),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=False,
               name='EnzoEdit')

 

 

 

From: [hidden email]
Sent: Tuesday, May 7, 2019 12:22 PM
To: [hidden email]
Subject: Re: [PyInstaller] win32com.client Issues

 

I am building a single directory. Oddly enough, I haven't been including the files in the .spec as data. I've just been dropping them into the directory afterwards. When I add them in the spec and rebuild, my script doesn't get past the initial logging messages. In the build warnings, i'm seeing a top-level warning that it could not include the win32com.genpy module. Not sure if that's related...

 

Since I'm building a one-folder bundle, my file locations should be correct with the pyinstaller defaults, no?

 

 

Regards,

 

Ben

 

On Sat, May 4, 2019 at 5:35 AM Elliot Garbus <[hidden email]> wrote:

Are you doing a single file build or a directory build?  You need to tell Pyinstaller where the files are located. Read the section in the docs on runtime information.

 

https://pyinstaller.readthedocs.io/en/stable/runtime-information.html

 

When your program is not frozen, the standard Python variable __file__ is the full path to the script now executing. When a bundled app starts up, the bootloader sets the sys.frozen attribute and stores the absolute path to the bundle folder in sys._MEIPASS. For a one-folder bundle, this is the path to that folder, wherever the user may have put it. For a one-file bundle, this is the path to the _MEIxxxxxx temporary folder created by the bootloader 

 

From: [hidden email]
Sent: Friday, May 3, 2019 12:54 AM
To: [hidden email]
Subject: Re: [PyInstaller] win32com.client Issues

 

Hi,

Please try out this solution if it can help you .

complete details are there.

 

On Sat, Apr 27, 2019 at 1:03 PM Ben Crews <[hidden email]> wrote:

Hello. I have a script which utilizes the win32com.client module and takes input from a spreadsheet to generate multiple word documents based on a standard template. This all works just fine in my dev environment, and with certain installations on other machines. When I try to package up the whole system, i've been running the basic pyinstaller myscript.py command. After it's packaged, I move the input and template files to the same directory as the exe, and some parts still work.

 

It seems like the Workbooks.Worksheets.Range() method doesn't work after I've packaged up. My code will register the win32com application object, and open up the input file. It will even read the data (I can see it output with logging statements), but when it gets to a line defining a range, it just stops.

 

logging.debug(startCell.Address) #Reports correct value in the log

logging.debug(endCell.Address)   #Reports correct value in the log

workingRange = InputSheet.Range(startCell, endCell).Value
logging.info(workingRange)

InputBook.Save()

InputBook.Close()


Through trial and error I've found that if I remove the "Value" the script will continue on to save and close the workbook, but will not log the data. I'm truly stumped, and I just don't get this error when running without pyinstaller.

 

 

I can't share the full code without authorization from my company, but does any of this sound familiar?

 

 

Thanks,

 

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


 

--

Regards,
Marx Chidambara Babu M.B

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.


 

--

-Ben

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CAKS55pDsbYSWfa7b6euMzJp02g7M4MTjL-xv7hwOQSDo2YQdLA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

 

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/5cd24966.1c69fb81.572cb.6a00SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.