System.Exception: ‘Python script exited with code 1.
Output:
Errors: Traceback (most recent call last):
File “C:Usersusers_j77wa4AppDataLocalProgramsPythonPython311Libsite-packagesopenseespyopensees_init_.py”, line 19, in
from openseespywin.opensees import *
File “C:Usersusers_j77wa4AppDataLocalProgramsPythonPython311Libsite-packagesopenseespywin_init_.py”, line 25, in
raise RuntimeError(
RuntimeError: Python version 3.8 is needed for Windows
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:Usersusers_j77wa4DesktopProjectXOutput3d_model.py”, line 2, in
import openseespy.opensees as ops
File “C:Usersusers_j77wa4AppDataLocalProgramsPythonPython311Libsite-packagesopenseespyopensees_init_.py”, line 22, in
raise RuntimeError(‘Failed to import openseespy on Windows.’)
RuntimeError: Failed to import openseespy on Windows.
‘
I got this RunTime error when i write the below code:
public static void Execute3DRendererModelScript()
{
SaveScript3DRendererModel();
string scriptPath = Properties.Settings.Default.OutputFolder + "\3d_model.py";
string pythonPath = Properties.Settings.Default.PythonInterpreter;
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = pythonPath,
Arguments = scriptPath,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
}
};
process.Start();
// Read the output/error of the Python script
string output = process.StandardOutput.ReadToEnd();
string errors = process.StandardError.ReadToEnd();
// Wait for the process to finish
process.WaitForExit();
// Handle errors if any
if (process.ExitCode != 0)
{
throw new Exception($"Python script exited with code {process.ExitCode}.nOutput: {output}nErrors: {errors}");
}
else
{
Console.WriteLine("Python script executed successfully.");
Console.WriteLine("Output: " + output);
}
}
but in reality when i open python3.11.exe then paste the my script here it works fine. what is the problem here?
I am trying to create .html file for openseespy 3D Renderer Model
Seyitcan Öz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.