Hi @Takashi Iijima, there's a few additional steps required to get the pywin32 module working with FME after installing following the instructions here.
You will need to copy the two dll's (pythoncom38.dll, pywintypes38.dll) in the pywin32_system32 directory of the target install location of win32com module to the FME install directory. Note two dll's installed on your system may be named differently if using a different version of FME (eg. pythoncom39.dll & pywintypes39.dll if using FME 2022).
Restart FME if it is currently open.
If you are still running into errors, add the following lines to your script before importing win32com in your script. You may need to change the paths to point to where you have downloaded win32com.
import sys
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32')
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32\lib')
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\Pythonwin')
Note: as the pywin32 module is non-universal, ensure the correct Python and bit-version of the module is downloaded. It is also highly recommended to specify the major and minor version for the destination folder when installing as it is non-universal.
Hi @Takashi Iijima, there's a few additional steps required to get the pywin32 module working with FME after installing following the instructions here.
You will need to copy the two dll's (pythoncom38.dll, pywintypes38.dll) in the pywin32_system32 directory of the target install location of win32com module to the FME install directory. Note two dll's installed on your system may be named differently if using a different version of FME (eg. pythoncom39.dll & pywintypes39.dll if using FME 2022).
Restart FME if it is currently open.
If you are still running into errors, add the following lines to your script before importing win32com in your script. You may need to change the paths to point to where you have downloaded win32com.
import sys
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32')
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32\lib')
sys.path.insert(0,r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\Pythonwin')
Note: as the pywin32 module is non-universal, ensure the correct Python and bit-version of the module is downloaded. It is also highly recommended to specify the major and minor version for the destination folder when installing as it is non-universal.
Thank you for your input @danminneyatsaf
Finally I was able to execute the script with the Python interpreter in FME 2021.2 Desktop.
What I did:
(1) Install win32com (pywin32) module.
fme.exe python -m pip install pywin32 --target C:\Users\<user>\Documents\FME\Plugins\Python\python38
(2) Copy these two dlls within "C:\Users\<user>\Documents\FME\Plugins\Python\python38\pywin32_system32" to FME 2021.2 Desktop install directory.
pythoncom38.dll
pywintypes38.dll
(3) Add these codes at the top of the script.
import sys
sys.path.insert(0, r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32')
sys.path.insert(0, r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32\lib')
Thank you for your input @danminneyatsaf
Finally I was able to execute the script with the Python interpreter in FME 2021.2 Desktop.
What I did:
(1) Install win32com (pywin32) module.
fme.exe python -m pip install pywin32 --target C:\Users\<user>\Documents\FME\Plugins\Python\python38
(2) Copy these two dlls within "C:\Users\<user>\Documents\FME\Plugins\Python\python38\pywin32_system32" to FME 2021.2 Desktop install directory.
pythoncom38.dll
pywintypes38.dll
(3) Add these codes at the top of the script.
import sys
sys.path.insert(0, r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32')
sys.path.insert(0, r'C:\Users\<user>\Documents\FME\Plugins\Python\python38\win32\lib')
Dear Takashi,
which script are you referring to exactly by "(3) Add these codes at the top of the script."?
Thanks,
Franco