How integrate Abaqus python libraries into a project hosted in PyCharm
abaqus, pycharm, python
Solution
I'm using abaqus 6.14-4, hopefully helpful for you. I think why we need PyCharm is because we want to fully use its type checker and other functions. If we only need a editor, then Abaqus PDE is enough.
In order to achieve this goal, I have been search for abaqus python's source code for long time and couldn't find it. Since abaqus only provide the compiled *.pyc files, I use the tool uncompyle6 to decode the *.pyc files and add some functions in it.
There is my project: abaqus_pycharm
register `\SIMULIA\Abaqus\6.14-4\tools\SMApy\python2.7\python.exe` as your interpreter (Or you can choose any you want)
copy the files at import-files folder to your site-packages folder
notices that this program used os.system command to run abaqus command line, shown as below:
def saveAs(self, pathName):
if isinstance(self.debug, bool) and self.debug:
print(pathName)
if 'ABAQUS_BAT_SETTING' in os.environ.keys():
self.abaqus_bat_setting = os.environ['ABAQUS_BAT_SETTING']
if 'ABAQUS_BAT_PATH' in os.environ.keys():
self.abaqus_bat_path = os.environ['ABAQUS_BAT_PATH']
os.system(self.abaqus_bat_path + ' cae -' + self.abaqus_bat_setting + ' ' + os.path.abspath(sys.argv[0]))
so we need to set environment like:
environ['ABAQUS_BAT_PATH'] = 'D:\\SIMULIA\\Abaqus\\Commands\\abaqus'
environ['ABAQUS_BAT_SETTING'] = 'noGUI'
and it will run as:
D:\SIMULIA\Abaqus\Commands\abaqus.bat -noGUI your_current_working_file.py
Problem
There is a similar question regarding the integration of Abaqus specific python libraries into a project hosted in `PyDev/Eclipse`. But unfortunately the answers were not compatible with my problem at hand. I am using `ABAQUS` Version 6.11-2 and the Community Edition of `PyCharm 3.1.3`. The Abaqus python interpreter resides at the following location on my windows7(64) machine.: ``` C:\SIMULIA\Abaqus\6.11-2\Python\Obj\Python.exe Python 2.6.2 for Abaqus 6.11-2 (r262:71600, Jun 29 2011, 19:23:41) [MSC v.1500 64 bit (AMD64)] on win32 ``` The libraries I need PyCharm to resolve in order to give it's code completion magic a go are residing here - at least that's what I believe them to be. ``` C:\SIMULIA\Abaqus\6.11-2\Python\Lib C:\SIMULIA\Abaqus\6.11-2\Python\Lib\abaqus.pyc C:\SIMULIA\Abaqus\6.11-2\Python\Lib\abaqusConstants.pyc ``` Here are the first lines of code of the script I am trying to work on. ``` from abaqus import * from abaqusConstants import * backwardCompatibility.setValues(includeDeprecated=True, reportDeprecated=False) import sketch import part ``` PyCharm marks the abaqus and abaqusConstants import with red underlining. Showing: ``` "Unresolved reference 'abaqus'". ``` Can someone explain to me how to configure the project in PyCharm so that PyCharm can resolve these imports? Adding the mentioned Python.exe as a Project Interpreter in the Settings Dialog will lead to the following error messagebox saying 'Cannot setup a python SDK at ~path~. The SDK seems invalid'. Regards