繁体   English   中英

如何在 jython 中导入模块?

[英]How to import module in jython?

我正在尝试在 Jython 中导入 Textblob 模块,但我没有收到NO MODULE WITH NAME异常。 我尝试了不同的模块,但出现了相同的异常。 虽然这个问题可能看起来很模糊,但这是唯一的问题。

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')");

这就是我解决它的方法,希望它可以帮助某人:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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