Intersystems Iris - embedded python
Hello,
I'm starting testing embedded python and external libraries.
When I try to use the win32api-library I get the following error :
<THROW> *%Exception.PythonException 230 ^^0^ <class 'ModuleNotFoundError'>: No module named 'win32api' -
This is my code :
ClassMethod CreateDocument(path As %String) [ Language = python ]
{
import win32api
...
}
The librarie is visible in C:\InterSystems\IRIS\mgr\python\win32.
Am I doing something wrong ?
Regards,
Kurt Hofman,
ASCI nv.
Comments
1. Try running:
cd <IRIS>\bin
./irispython "C:\InterSystems\IRIS\lib\python\Scripts\pywin32_postinstall.py" -installIt might fix your error.
If that does not help, add win32 folder to path explitictly and try import again:
import sys
sys.path.append("<IRIS>\Mgr\python\win32")
import win32apiThere is no C:\InterSystems\IRIS\lib\python\Scripts\pywin32_postinstall.py
Looks like win32api in not installed with IRIS.
Try to install win32api module by running below command :
C:\InterSystems\IRIS\bin>irispip install --target C:\InterSystems\IRIS\mgr\python win32apiReplace C:\InterSystems by your IRIS installation folder
For more details please check below link
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…
I get this error :
PS C:\Users\kurthofman> C:\InterSystems\IRIS\bin\irispip install --target C:\InterSystems\IRIS\mgr\python win32api
ERROR: Could not find a version that satisfies the requirement win32api (from versions: none)
ERROR: No matching distribution found for win32api
Looks like there are some restrictions while installing win32api with pip
Try with pypiwin32 module as below:
C:\Users\kurthofman> C:\InterSystems\IRIS\bin\irispip install --target C:\InterSystems\IRIS\mgr\python pypiwin32
I installed pypiwin32
ClassMethod Test() [ Language = python ]
{
import win32api
}
USER>Do ##class(User.Demo).Test()
DO ##CLASS(User.Demo).Test()
^
<THROW> *%Exception.PythonException <THROW> 230 ^^0^ <class 'ModuleNotFoundError'>: No module named 'win32api' -
USER>
Hello @Kurt Hofman ,
I experienced a similar problem the last week while testing a library.
To solve it, I created the PYTHONPATH system environment variable with C:\InterSystems\IRISHealth\lib\python\Lib\site-packages\win32;C:\InterSystems\IRISHealth\lib\python\Lib\site-packages\win32\lib.
IRIS need to be restarted to consider any change in an environment variable.
Check If pythoncom39.dll and pywintypes39.dll exist in the directory C:\InterSystems\IRISHealth\lib\python\Lib\site-packages\win32. If they don't exist, copy them. I don't remember the initial directory of these dll files (maybe C:\InterSystems\IRISHealth\mgr\python\pywin32_system32).
I'm a beginner in Python, so maybe a more simple and clean solution exists...
Hope this help.