GeoStudio | PLAXIS Forum - Running Plaxis from Pycharm
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Running Plaxis from Pycharm

by
Farbod Yarmohammadi
Rising Star

Hi,

Im trying to run my plaxis python code using Pycharm and as soon as the code reaches "import plxscripting.easy", Ill get ImportError:

"ImportError: cannot import name 'MutableMapping' from 'collections' (C:\Users\Farbod\AppData\Local\Programs\Python\Python310\lib\collections\__init__.py)"

I saw in another question that we need to change the python interpreter in pycharm and choose the one in plaxis directory. But when I do that, pycharm tells me that the interpreter Ive selected is invalid. 

I'm quite confused and I appreciate if you can point me in the right direction. 

Cheers

Topics: PLAXIS 2D python

Accepted Solution

Dear Farbod,

Indeed, if PLAXIS is not running you cannot just try to start a new_server. The generic workflow would be to have PLAXIS running first, activating the server with a port and a password and then running your script.

If you want to skip this part, then as with any Windows application, Python can launch it using a different module. For instance:

import subprocess
subprocess.Popen([r"C:\Program Files\Bentley\Geotechnical\PLAXIS 2D CONNECT Edition V22\Plaxis2DXInput.exe", "--AppServerPort=10000", "--AppServerPassword=YourPassword"])

from plxscripting.easy import *
s_i, g_i = new_server('localhost', 10000, password='YourPassword')

# add your code here