IDEALib for Python

5 posts / 0 new
Last post
bryan3contreras
Offline
Joined: 11/23/2022 - 12:04
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 11/23/2022 - 12:04

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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?

bryan3contreras
Offline
Joined: 11/23/2022 - 12:04

Ok. Than you so much. I will try and give you feedback
About your question. If IDEA is already open, I don´t have the problem. My file explorer is refresh.