[英]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.