Skip to content

spacy error 'no module named spacy' / Ironpython #730

@gazakhova

Description

@gazakhova

###I am trying to run a Python script with Spacy NER model on C# using Dynamic Py.

  1. I used following C# source code:
using System;
using IronPython.Hosting;
using System.Collections.Generic;
using System.Text;

namespace PythonTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Python integrieren");
            Console.ReadLine();

            var engine = Python.CreateEngine();
            try
            {
                engine.ExecuteFile(@"C:\Users\Admin\source\repos\DynamicPy\script.py");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Python wurde integriert!" + ex.Message);
            }

            Console.WriteLine("Ende");
            Console.ReadLine();
        }
    }
}

  1. Then I created a simple python code for Spacy's Named Entity Recognition:
import spacy
nlp = spacy.load("en_core_web_sm")
text = ("This is an example text.")

doc = nlp(text)
for entity in doc.ents:
    print(entity.label_, ": ", entity.text)

** I expected that Spacy's model would be read via C # and relevant entities would be recognized.

**But I get the error 'no module named spacy'

**
I am using:
Visual Studio 2019
Python: 3.7.5
Spacy: v2.3.2
IronPython: 2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions