1

I am trying to run python script from c# using Ironpython but I get error like in title.

Here's the code part. It fails while importing in python

c#

                var engine = Python.CreateEngine();
                var source = engine.CreateScriptSourceFromFile(templateLocation.Text + @"\test.py");
                var searchPaths = engine.GetSearchPaths();
                searchPaths.Add(templateLocation.Text+@"\Modules");
                engine.SetSearchPaths(searchPaths);
                List<String> argv = new List<String>();
                argv.Add(year.Text);
                argv.Add(filesLocation.Text);
                argv.Add(templateLocation.Text);
                argv.Add(reportLocation.Text);
                var scope = engine.CreateScope();
                engine.GetSysModule().SetVariable("argv", argv);
                source.Execute(scope);

Python

import sys
yearForm = sys.argv[0]
fileLocation = sys.argv[1].replace("\\","/")
exeLocation = sys.argv[2].replace("\\","/")
saveLocation = sys.argv[3].replace("\\","/")
sys.path.insert(1,exeLocation+"/Modules/")
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.colors as cls
from matplotlib.colors import ListedColormap
from matplotlib.artist import setp
from pandas import ExcelWriter
import os

and let me just add that exeLocation is: C:\Users\Zlatko\name-annual-report

1
  • IronPython is not compatible with python 3.x Commented Oct 7, 2019 at 16:14

1 Answer 1

1

what i could see, you cant execute this Python Script with ironpython: one reason is module Pandas for example, Pandas is pretty well tied to CPython.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.