Jython and python script encoding incompatibilty

*爱你&永不变心* 提交于 2019-12-11 16:49:35

问题


I have a Python script created on Python 3.5.4. The script is importing nltk. When I am trying to execute the script from java using Jython 2.7.1 it is giving me following errors.

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

Also when I checked the default encoding of Python and Jython then the result was utf-8 and ascii respectively.

来源:https://stackoverflow.com/questions/46968333/jython-and-python-script-encoding-incompatibilty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!