Skip to main content

IDEALib for Python

HI. I'm recently working with IDEA and Python.I read in the documentation that it is possible to use the IDEALib library.My question is how do I install the library in Pycharm or VSCode?
Do I need to copy from the site package into my Python path?
I have a problem.When I run my script it says No module named 'win32api'
Regards

Brian Element Thu, 12/08/2022 - 06:06

Hi Bryan, 

The IDEALib.py is installed in the IDEA program directory.  To be able to use it outside of IDEA you will have to copy it to your python project folder.  The file can be found here: C:\Program Files\CaseWare IDEA\IDEA\Lib\site-packages

In order to use the win32api I believe you need to install this python module into your python environemnt - python -m pip install pypiwin32

 

bryan3contreras Thu, 12/08/2022 - 11:16

Thanks Brian.I did it and it worked.I have one more problem, I am running my code using IDEALib in my python IDE but when I open IDEA I get a message that IDEA can only run one task at a time.What do you recommend to stop the code?I thought this would work, but it didn't.
 
import sys
...
sys.exit()

Brian Element Fri, 12/09/2022 - 07:39

That is interesting, I haven't seen that before.  You can only have one IDEA instance open at a time, so if you script is still running and hasn't released IDEA that could be causing a problem.  I am not sure of your code but if you are using any IDEA tasks or accessing the database make sure you clear out the variables in Python by making them equal to None.

In IDEAScript there is also the client.Quit() command but generally the only time you would use that is in a lights out operation where you have a script scheduled to open IDEA, run a process and close IDEA.

If IDEA is already open when you run it from you IDE do you also have a problem?

The website encountered an unexpected error. Try again later.