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

Use this forum to post Vensim related questions.
Post Reply
gyucel
Member
Posts: 20
Joined: Fri Apr 02, 2004 1:47 pm

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

Post 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}")
Administrator
Super Administrator
Posts: 4848
Joined: Wed Mar 05, 2003 3:10 am

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

Post by Administrator »

Your path to the DLL is wrong. Why did you move the DLL to "c:\program files (x86)\vensim"?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
melistugrul
Newbie
Posts: 1
Joined: Thu May 16, 2024 11:22 am
Vensim version: PLE

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

Post 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?
tomfid
Administrator
Posts: 4004
Joined: Wed May 24, 2006 4:54 am

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

Post by tomfid »

Sounds like an installer issue. Manually move the dll to \program files\ ?
Administrator
Super Administrator
Posts: 4848
Joined: Wed Mar 05, 2003 3:10 am

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

Post 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?
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply