Jieba: Import error, cannot find paddle.fluid and jieba.lac_small.predict module

327 views Asked by At

I am trying to use Jieba (a Chinese text segment tool) with Paddle. Here is the code:

import jieba # v0.42.1 
import paddle # v2.5.1 paddlepaddle-gpu

paddle.enable_static()
jieba.enable_paddle()

text = '我是一個男生' # means "I am a boy."
seg_list = jieba.cut(text, use_paddle=True)

In the output, it said:

Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......
[2023-09-12 20:33:33,413] [   DEBUG] _compat.py:50 - Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......

I'm using the latest version of paddle and jieba. Jieba library also suggests to install paddlepaddle-tiny==1.6.1., but a suitable candidate cannot be found in my current settings (Python 3.9.7).

How can I solve this problem?


UPDATE If I remove the 2 enable_ lines, the warning is gone.

1

There are 1 answers

2
san zhang On

This error message indicates that jieba attempts to start Paddle mode, but falls back to the basic segmentation mode because paddle.fluid and jieba.lac_small.predict modules cannot be found. This indicates that PaddlePaddle is not installed correctly in your environment, or the version installed is not compatible. This error will affect the PaddlePaddle-based deep learning segmentation mode with jieba, but it will not affect the basic segmentation function of jieba. If your project does not require deep learning segmentation, then this error will not matter much to you. The basic jieba word segmentation mode can still be used normally, and the dictionary is successfully constructed, as shown at the end of the error message. However, if your project requires PaddlePaddle for more advanced text processing features, then you'll need to fix this error, install the correct PaddlePaddle version, and make sure all the dependencies have been met. How to solve this problem, I have mentioned in the previous answer. You need to make sure PaddlePaddle library is installed correctly, or check if jieba has a newer version that supports the features you need.