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
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
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 subprocesssubprocess.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
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 = 10000localhostport_output = 10001s_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
Great that it helped!
Indeed you are missing the password parameter in the new_server function.
The boilerplate is:
from plxscripting.easy import * s_i, g_i = new_server('localhost', 10000, password='yourpassword')
You can find this here: communities.bentley.com/.../using-plaxis-remote-scripting-with-the-python-wrapper
Hi Stefanos,
Amazing. That solved that issue. But now when I wanna run my code in PyCharm, I get the following error:
Exception: Couldn't get AppServerPassword from command line arguments.
This is the boilerplate Im using in my code:
from plxscripting.easy import *import plxscripting.easyimport mathimport weakrefimport win32apilocalhostport_input = 10000localhostport_output = 10001s_i, g_i = new_server('localhost', localhostport_input)s_o, g_o = new_server('localhost', localhostport_output)If I delete the last two lines, I will get the error "s_i not recognized".Also, if I change the last two lines to these:
s_i, g_i = new_server('localhost', localhostport_input, password = 'password')s_o, g_o = new_server('localhost', localhostport_output, password = 'password')I will get the error below when I execute the s_i.new() command:plxscripting.plx_scripting_exceptions.PlxScriptingError: The server failed to decrypt the request. This probably means the password on the client does not match the one on the server.Is there any other boilerplate code I should use?Thank you very much again,Cheers,