question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using live-py with Abaqus' python distribution

See original GitHub issue

Hello again,

Disclamer: I wrote this before having read the built in Emacs documentation.

System information

  • Windows 10
  • System Python: Python 2.7.13 :: Anaconda 4.3.1 (64-bit)
  • GNU Emacs 25.1.1 (x86_64-w64-mingw32) of 2016-11-15
  • Spacemacs v.0.200.9
  • live-py-mode-20170429.2207
  • Abaqus 2017
  • abaqus python --version gives 2.7.3

Overview

I’d like to use Live-py with Abaqus’ python distribution. The documentation is usually comprehensive.

I’ve tried various things, probably in all the ways they were not intended. Not sure if this can be done in Live-py, but I’d really like to give it a shot.

I’ll try to provide any other debug information that may be useful.

Step 1: live-py-set-version with python interpreter and arguments

Using M-x live-py-set-version, I was able to specify a custom python interpreter.

To run Python applications in an Abaqus context, the command abaqus python can be used; thus if I want to run my own_script.py, I execute abaqus python own_script.py in a terminal. I then have access to the custom Abaqus imports that allows me to interact with FEM models and analysis results. The abaqus command resolves to the batch script C:\SIMULIA\Commands\abaqus.bat on my system, which starts C:\SIMULIA\CAE\2017\win_b64\code\bin\ABQLauncher.exe with any arguments list (eg python own_script.py passed through). The executable then again passes control to a bundled python.exe, after doing some magic that allows me to access the API. I haven’t been able to load the API on a python.exe of my choosing without going through this magic executable.

When I M-x live-py-set-version "c:/SIMULIA/Commands/abaqus.bat python", I get this in the preview Window:

'"c:/SIMULIA/Commands/abaqus.bat python"' is not recognized as an internal or external command,
operable program or batch file.
  • Is it possible to specify arguments to the Python interpreter used with live-py?

Step 2: Custom batch script that wraps arguments

  1. I create apyth.bat in the same directory as own_script.py containing
    "C:\SIMULIA\Commands\abaqus.bat" python %*
    
  2. I set my M-x live-py-set-version to apyth, and it seems to be getting a little further:
    d:\workspace\python>"C:\SIMULIA\Commands\abaqus.bat" python "c:/Users/thlhe/.emacs.d/elpa/live-py-mode-20170429.2207/code_tracer.py" -f "d:/workspace/python/abaqus_live.py" - abaqus_live python 
    Traceback (most recent call last):
      File "c:/Users/thlhe/.emacs.d/elpa/live-py-mode-20170429.2207/code_tracer.py", line 23, in <module>
        arg = locate('ast.arg')
      File "C:\SIMULIA\CAE\2017\win_b64\tools\SMApy\python2.7\lib\pydoc.py", line 1471, in locate
        nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
      File "C:\SIMULIA\CAE\2017\win_b64\tools\SMApy\python2.7\lib\pydoc.py", line 310, in safeimport
        raise ErrorDuringImport(path, sys.exc_info())
    pydoc.ErrorDuringImport: problem in ast.arg - <type 'exceptions.ImportError'>: No module named arg
    
  3. Seems like the locate function behaves differently with the two python interpreters, returning None on Anaconda Python 2.7 and throwing an error with Abaqus Python 2.7: image

Step 3: Attempting to fix the locate issue

I tried modifying the beginning of code_tracer.py to this to wrap the error:

import pydoc # no longer import the locate function
import sys
import traceback
import types
import os
import importlib

from canvas import Canvas
from mock_turtle import MockTurtle
from report_builder import ReportBuilder

# Instead, wrap it in a try-catch
def locate(*args, **kwargs):
    try:
        return pydoc.locate(*args, **kwargs)
    except ImportError:
        return None

But I still kept getting the same error. My suspect is my lack of understanding plugin internals.

Summary

  1. Trying to specify which abaqus interpreter to use was a little clunky, especially with command line arguments. live-py-set-version may be the wrong function to use? Is there a better way?
  2. I’d like feedback on how to fix the error with locate.

Ideas?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
donkirkbycommented, Jun 8, 2017

I noticed the same thing on Ubuntu when specifying a virtualenv or Python 3, so I’ve opened issue #123.

Thanks for letting me know that the interpreter arguments are working.

1reaction
donkirkbycommented, May 25, 2017

I added the live-py-set-args command (C-c M-a). You should be able to set the version to abaqus and the args to python.

Read more comments on GitHub >

github_iconTop Results From Across the Web

#1 Step-by-Step Guide for Professional ABAQUS-Python ...
from abaqus import *from abaqusConstants import *# functionsdef Create_Part_3D_Cylinder(radius,length,thickness,part,model): s1 ...
Read more >
Abaqus python scripting: how difficult is it? - Simuleon
In Abaqus PDE select File --> Open and open abaqusMacros.py. This is in the home or the work directory, depending on where you...
Read more >
Hello everyone, I am trying to import python libraries such as ...
Use Abaqus Python to do operations that need Abaqus libraries, like creating models, extracting results from an odb, ... and store your results...
Read more >
Parallelism calculator english - Sport Castellano Reports
Easy to use online geometry calculators and solvers for various topics in geometry such as calculate area, volume, distance, points of intersection. Python...
Read more >
pyabaqus - PyPI
Type hints for Abaqus/Python scripting. ... use conda to install (the ipyparams package is only distributed in PyPI , so you have to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found