简体   繁体   中英

How to import module in jython?

I am trying to import the Textblob module in Jython, but I am getting NO MODULE WITH NAME exception. I have tried different modules but the same exception appears. Though this question may seem vague thats the only problem.

Properties p = new Properties();
        p.setProperty("python.console.encoding", "UTF-8");
        PySystemState systemState = Py.getSystemState();
        systemState.path.append(new PyString("C:\\jython2.7.1\\Lib")); 
        systemState.path.append(new PyString("C:\\jython2.7.1\\Lib\\site-packages"));
        systemState.path.append(new PyString("C:\\jython2.7.1\\pkgs"));

        PythonInterpreter.initialize(System.getProperties(), p, new String[] {});
        PythonInterpreter python = new PythonInterpreter();


        python.exec("from nltk.corpus import stopwords\ncachedStopWords = stopwords.words('english')");

This is how I solved it,Hope it helps someone:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM