简体   繁体   中英

How to import a Python module into Jython?

I can use the module correctly by Python, but when using Jython, some error occurs... Code:

from jieba import *

Errors:

Traceback (most recent call last):
  File "/Users/Jack/Documents/workspace/FirstJython/hellojyphon.py", line 8, in <module>
    from jieba import *
  File "/Users/Jack/Documents/workspace/FirstJython/jieba/__init__.py", line 15, in <module>
    from ._compat import *
ImportError: No module named _compat

Is there any differences between Python and Jython when import?

I solve it by myself. There is something wrong when using relative directories in Jython. so after I change ._compat to jieba._compat, the problem solved! But I don't exactly know the reason...

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