Page 1 of 1

Issue with Python Integration of Vensim Model (Reinstall Vensim Error 977)

Posted: Fri Sep 20, 2024 10:28 am
by gyucel
I am encountering difficulties integrating my Vensim DSS model with Python. However, when attempting to load the Python model through Visual Studio, I receive a "Reinstall Vensim" prompt. I have reinstalled and updated Vensim, Python, and Visual Studio (using "Run as Administrator") three times, but the issue persists. Additionally, there are no other users on my PC, and I am using my account with administrator privileges.

Could you please assist me with this issue? If you have any suggestions or additional instructions to resolve this problem, I would greatly appreciate it. You can see all of my specifications below.

Windows Specification:

Edition Windows 10 Pro
Version 22H2
Installed on ‎27.‎11.‎2020
OS build 19045.3324
Experience Windows Feature Experience Pack 1000.19041.1000.0

About Vensim:

DSS 10.2.1

The Code:


import ctypes
import os

# Step 1: Load the Vensim DLL using ctypes
vensim_dll_path = r'C:\Program Files (x86)\Vensim\vendll64.dll'
vensim = ctypes.windll.LoadLibrary(vensim_dll_path)
if vensim:
print("Vensim DLL loaded successfully.")
else:
raise Exception("Failed to load Vensim DLL.")

# Define Vensim function prototypes
vensim_command = vensim.vensim_command
vensim_command.argtypes = [ctypes.c_char_p]
vensim_command.restype = ctypes.c_int

# Step 2: Load the Vensim model
def load_vensim_model(model_path):
model_path_bytes = model_path.encode('utf-8')
load_status = vensim_command(f"SPECIAL>LOADMODEL|{model_path}".encode('utf-8'))

if load_status == 1:
print("Model loaded successfully!")
else:
print(f"Failed to load the model. Check if the model path is correct or if the model is in the correct format.")

print(f"Load status: {load_status}")
return load_status

# Use the published model (.vpm or .vpmx)
model_path = r'C:\Users\....\Desktop\DEMOfinal.vpmx'

# Check if the model exists and then attempt to load it
if os.path.exists(model_path):
print(f"Model found at: {model_path}")
load_vensim_model(model_path)
else:
print(f"Model not found at: {model_path}")

Re: Issue with Python Integration of Vensim Model (Reinstall Vensim Error 977)

Posted: Fri Sep 20, 2024 10:34 am
by Administrator
Your path to the DLL is wrong. Why did you move the DLL to "c:\program files (x86)\vensim"?

Re: Issue with Python Integration of Vensim Model (Reinstall Vensim Error 977)

Posted: Tue Sep 24, 2024 6:28 pm
by melistugrul
Hi, I have the same problem too. When I reinstall Vensim, dll file is automatically downloaded to "c:\program files (x86)\vensim" file. What can I do in that situation?

Re: Issue with Python Integration of Vensim Model (Reinstall Vensim Error 977)

Posted: Wed Sep 25, 2024 1:59 pm
by tomfid
Sounds like an installer issue. Manually move the dll to \program files\ ?

Re: Issue with Python Integration of Vensim Model (Reinstall Vensim Error 977)

Posted: Wed Sep 25, 2024 4:21 pm
by Administrator
melistugrul wrote: Tue Sep 24, 2024 6:28 pm Hi, I have the same problem too. When I reinstall Vensim, dll file is automatically downloaded to "c:\program files (x86)\vensim" file. What can I do in that situation?
Your profile says you are a PLE user, the DLL does not come with PLE.

Or did you get the DLL from somewhere else?