Hello,
Since I am working with plaxis connect my python scripts which use pandas are not working anymore.
I followed the steps in this thread, without success.
https://communities.bentley.com/products/geotech-analysis/w/wiki/51822/how-to-install-additional-python-modules-in-plaxis
My Plaxis version is 22.00.00.1733
I am used the build in python editor: Python 3.8.10
The panda version I downloaded with pip is: 1.4.4
File "C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution V2\python\lib\site-packages\defusedxml\ElementTree.py", line 68, in __init__ _XMLParser.__init__(self, html, target, encoding)TypeError: __init__() takes 1 positional argument but 4 were given
import pandas as pd
######################################################### Connect python-plaxis #########################################################
pw = "XXXX"
# PLAXIS 3D localhostport_input = 10000 localhostport_output = 10001from plxscripting.easy import *s_i, g_i = new_server('localhost', localhostport_input, password=pw) s_o, g_o = new_server('localhost', localhostport_output, password=pw)
filename1='220915_RFEM_Auflagerreaktionen-erdbeben.xlsx'
df_knoten=pd.read_excel(filename1, sheet_name=0,header=0) # Knoten / Nodes # this line has the error
Dear Marijn,
It seems that pandas use this module, however, there is an incompatibility. I did some research online to find that a specific version was causing problems.
As the PLAXIS version you are using is not our latest released, can you please check and upgrade the defusedxml to the latest version?In my case upgrading to 0.7.1 seems to have solved the problem.
Note that as we deliver various modules with PLAXIS it is not easy to track each and every bug modules may have and their compatibility with third-party modules.
Answer Verified By: marijn de volder
Hello,I have a similar problem with Python version 3.11.1. My script works perfectly in the input program without pandas. When I try to use pandas inside a script, it will stop running. my defusedxml is version 0.7.1. I've also tried with the integrated python interpreter and still doesn't work. I've installed pandas from the command prompt inside the input program. My Plaxis version is 22.2.0.1078.
It works now. The problem was that I had to pass the whole path to the excel file inside the pd.read_excel method, even though the excel file and the python script are in the same folder.for example:file = pd.read_excel("MyExcel", sheet_name="Sheet1") will not work. file = pd.read_excel("C:\PythonScripts\MyExcel", sheet_name="Sheet1") will work.