Jython和Python脚本编码不相容性(Jython and python script enc

2019-10-30 12:09发布

我有关于Python 3.5.4创建一个Python脚本。 该脚本导入NLTK。 当我试图使用从Java执行脚本的Jython 2.7.1它给我下面的错误。

Exception in thread "MainThread" java.lang.ExceptionInInitializerError
Caused by: Traceback (most recent call last):
  File "D:\TensorFlow\TflearnExample\ChatBot.py", line 9, in <module>
    import nltk
  File "D:\Python\Lib\site-packages\nltk\__init__.py", line 137, in <module>
    from nltk.stem import *
  File "D:\Python\Lib\site-packages\nltk\stem\__init__.py", line 29, in <module>
    from nltk.stem.snowball import SnowballStemmer
  File "D:\Python\Lib\site-packages\nltk\stem\snowball.py", line 26, in <module>
    from nltk.corpus import stopwords
  File "D:\Python\Lib\site-packages\nltk\corpus\__init__.py", line 66, in <module>
    from nltk.corpus.reader import *
  File "D:\Python\Lib\site-packages\nltk\corpus\reader\__init__.py", line 105, in <module>
    from nltk.corpus.reader.panlex_lite import *
  File "D:\Python\Lib\site-packages\nltk\corpus\reader\panlex_lite.py", line 15, in <module>
    import sqlite3
SyntaxError: Non-ASCII character in file 'D:\Python\Lib\sqlite3\__init__.py', but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

此外,当我检查的Python和Jython的默认编码然后将结果分别为UTF-8和ASCII。

文章来源: Jython and python script encoding incompatibilty