Running Plaxis from Pycharm

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

Parents Reply Children
  • Thank you for the reply Stefanos. I really appreciate your help. 

    But as I mentioned in my previous comment, when I use this code:

    from plxscripting.easy import *

    localhostport_input = 10000
    localhostport_output = 10001

    s_i, g_i = new_server('localhost', 10000, password='YourPassword')
    s_o, g_o = new_server('localhost', localhostport_output, password='YourPassword')



    It leads to the following error:
    plxscripting.requests.exceptions.ConnectionError: HTTPConnectionPool(host='192.168.12.12', port=10000): Max retries exceeded with url: /environment (Caused by <class 'TimeoutError'>:
    [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)



    The only way I can get it to work, is to manually start the server with the same password and same port from
    Plaxis and then run this code.

    Is there any way to run this code without having to manually starting the server from Plaxis?

    Thank you very much again,

    Farbod
  • 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

    Answer Verified By: Farbod Yarmohammadi 

  • Genius! Thanks Stefanos. 

    Just in case anybody wants to use this in the future, in the code above I think "--Password = YourPassword" should be changed to:

    "--AppServerPassword=YourPassword".

    Thanks again,
    Farbod