1

Is the Pythonnet project still supported?

Portal is not recognized in code below and I can't find much documentation.

     PythonEngine.Initialize();
        PyObject pyportal = PythonEngine.ImportModule("PyPortal");
        PyObject callable = pyportal.GetAttr("invoke");
        Portal portal = new Portal();
        object[] objects = portal.Invoke(callable, "Mark Barclay", 123.456);
        if (objects != null)
        {
            foreach (object o in objects)
            {
                if (o != null)
                    Console.WriteLine(o.ToString());
                else
                    Console.WriteLine("o is null.");
            }
        }
8
  • You can't instantiate classes from Python like that Commented Jul 20, 2016 at 13:38
  • This is in c#. As detailed here pythondotnet.python.narkive.com/WK3v2R0p/… Commented Jul 20, 2016 at 13:41
  • I see, I think it is explained further below how to import it Commented Jul 20, 2016 at 13:53
  • But seems like a very old project. I can't seem to find anything more modern though Commented Jul 20, 2016 at 13:55
  • Did you add the portal class to your project? Like @Andrey said further down on that link he states you need to create the Portal.cs class in your project your self. Commented Jul 20, 2016 at 13:59

1 Answer 1

1

I also found this example when starting to explore python for .NET. It actually refers to an old version of pythonnet, the new version has documentation here: pythonnet. I'll be honest I'm still having trouble getting my imports to work, but many others seem to have success with this. You can install with a pip install which I found very handy. This troubleshooting page has also been helpful for me. Goodluck!

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.