0

I'm new for both python and ironpython. Can you you help me how to call external python script from ironpython? I have a script file like

import sys

def sample():
    from PIL import Image, ImageEnhance, ImageFilter
    img = Image.open("C:\\python\\images4.jpg")
    img.show(img)

My ironpython from console application.

class Program
    {
        static void Main(string[] argsS)
        {
            var engine = Python.CreateEngine();
            dynamic scope = engine.CreateScope();
            engine.ExecuteFile(@"C:\\pythonscripts\\pythonCheckV.py",scope);
            scope.sample();
            Console.Read();
        }
    }

2 Answers 2

1

PIL won't currently work with IronPython because it uses a native C library.

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

Comments

0

You Shouldn't import Libs inside a function , it's a bad practice, though i don't know much about IronPython but your Python Script should be something like this :

import sys
from PIL import Image, ImageEnhance, ImageFilter

def sample():
    img = Image.open("C:\\python\\images4.jpg")
    img.show(img)

If you still using old PIL , it's no longer maintained, You Should instal Pillow, it's the successor of PIL

Following Question May help you:

How do I pass arguments to a Python script with IronPython

1 Comment

Thanks for you are response i will check and let you know.

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.