Skip to content

Replace pkg_resources with importlib.resources to suppress deprecation warning#1044

Open
ParkSnoopy wants to merge 3 commits intofxsjy:masterfrom
ParkSnoopy:master
Open

Replace pkg_resources with importlib.resources to suppress deprecation warning#1044
ParkSnoopy wants to merge 3 commits intofxsjy:masterfrom
ParkSnoopy:master

Conversation

@ParkSnoopy
Copy link

Unittest log, on Windows, with Python 3.13.7
3 errors, but when I test with the unmodified repo, the same error is omitted.
I couldn't figure out what to supply as CLI args.

C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\test>uv run -- python -m unittest

Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
Loading model cost 0.833 seconds.
Prefix dict has been built successfully.
又 d
跛 a
又 d
啞 v
===> Thread 1:17104 started
Building prefix dict from the default dictionary ...
===> Thread 1:4092 started
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
===> Thread 1:7540 started
Building prefix dict from the default dictionary ...
Building prefix dict from the default dictionary ...
===> Thread 1:18948 started
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
Building prefix dict from the default dictionary ...
===> Thread 2:14764 started
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
===> Thread 2:10868 started
===> Thread 1:11776 started
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
===> Thread 2:14592 started
===> Thread 2:10428 started
===> Thread 2:4628 started
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
Building prefix dict from the default dictionary ...
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Loading model cost 1.395 seconds.
Prefix dict has been built successfully.
<=== Thread 2:14764 finished
Loading model cost 2.265 seconds.
Prefix dict has been built successfully.
<=== Thread 2:10868 finished
Loading model cost 2.905 seconds.
Prefix dict has been built successfully.
<=== Thread 1:17104 finished
Loading model cost 1.734 seconds.
Loading model cost 3.086 seconds.
Loading model cost 1.774 seconds.
Prefix dict has been built successfully.
<=== Thread 2:4628 finished
Loading model cost 3.329 seconds.
Prefix dict has been built successfully.
<=== Thread 1:18948 finished
Loading model cost 3.531 seconds.
Prefix dict has been built successfully.
<=== Thread 1:4092 finished
Loading model cost 2.561 seconds.
Prefix dict has been built successfully.
<=== Thread 1:7540 finished
Prefix dict has been built successfully.
<=== Thread 2:10428 finished
Prefix dict has been built successfully.
Loading model cost 2.974 seconds.
<=== Thread 2:14592 finished
Prefix dict has been built successfully.
<=== Thread 1:11776 finished
========================================
===> Thread 1:6380 started
Building prefix dict from the default dictionary ...
===> Thread 1:7216 started
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.cache
===> Thread 1:8704 started
===> Thread 1:15200 started
===> Thread 1:10388 started
===> Thread 2:16684 started
Building prefix dict from C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\extra_dict\dict.txt.small ...
===> Thread 2:19140 started
===> Thread 2:12520 started
===> Thread 2:1264 started
===> Thread 2:7940 started
Loading model from cache C:\Users\sunwoo\AppData\Local\Temp\jieba.u962b929070036b866aa80ff05b0d197c.cache
Loading model cost 0.441 seconds.
Prefix dict has been built successfully.
<=== Thread 2:16684 finished
<=== Thread 2:19140 finished
<=== Thread 2:1264 finished
<=== Thread 2:12520 finished
<=== Thread 2:7940 finished
Loading model cost 0.764 seconds.
Prefix dict has been built successfully.
<=== Thread 1:6380 finished
<=== Thread 1:7216 finished
<=== Thread 1:15200 finished
<=== Thread 1:8704 finished
<=== Thread 1:10388 finished
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Default Mode:我/ 来到/ 北京/ 清华大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
他, 来到, 了, 网易, 杭研, 大厦
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Default Mode:我/ 来到/ 北京/ 清华大学
Default Mode:我/ 来到/ 北京/ 清华大学
Default Mode:我/ 来到/ 北京/ 清华大学
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Default Mode:我/ 来到/ 北京/ 清华大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
他, 来到, 了, 网易, 杭研, 大厦
他, 来到, 了, 网易, 杭研, 大厦
他, 来到, 了, 网易, 杭研, 大厦
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Full Mode:我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学
Default Mode:我/ 来到/ 北京/ 清华大学
他, 来到, 了, 网易, 杭研, 大厦
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
Default Mode:我/ 来到/ 北京/ 清华大学
Default Mode:我/ 来到/ 北京/ 清华大学
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
Default Mode:我/ 来到/ 北京/ 清华大学
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
他, 来到, 了, 网易, 杭研, 大厦
Default Mode:我/ 来到/ 北京/ 清华大学
他, 来到, 了, 网易, 杭研, 大厦
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
他, 来到, 了, 网易, 杭研, 大厦
他, 来到, 了, 网易, 杭研, 大厦
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
他, 来到, 了, 网易, 杭研, 大厦
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, ,, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造
Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......
[2025-10-14 16:03:27,272] [   DEBUG] _compat.py:45 - Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......
Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......
[2025-10-14 16:03:27,278] [   DEBUG] _compat.py:45 - Import error, cannot find paddle.fluid and jieba.lac_small.predict module. Now, back to jieba basic cut......
李小福/是/创新办/主任/也/是/云计算/方面/的/专家/;/ /什么/是/八一双鹿/
/例如/我/输入/一个/带/“/韩玉赏鉴/”/的/标题/,/在/自定义/词库/中/也/增加/了/此/词为/N/类/
/「/台中/」/正確/應該/不會/被/切開/。/mac/上/可/分出/「/石墨烯/」/;/此時/又/可以/分出/來/凱特琳/了/。
========================================
李小福 / nr ,  是 / v ,  创新办 / i ,  主任 / b ,  也 / d ,  是 / v ,  云计算 / x ,  方面 / n ,  的 / uj ,  专家 / n ,  ; / x ,    / x ,  什么 / r ,  是 / v ,  八一双鹿 / nz ,
 / x ,  例如 / v ,  我 / r ,  输入 / v ,  一个 / m ,  带 / v ,  “ / x ,  韩玉赏鉴 / nz ,  ” / x ,  的 / uj ,  标题 / n ,  , / x ,  在 / p ,  自定义 / l ,  词库 / n ,  中 / f ,  也 / d ,  增加 / v ,  了 / ul ,  此 / r ,  词 / n ,  为 / p ,  N / eng ,  类 / q ,
 / x ,  「 / x ,  台中 / s ,  」 / x ,  正確 / ad ,  應該 / v ,  不 / d ,  會 / v ,  被 / p ,  切開 / ad ,  。 / x ,  mac / eng ,  上 / f ,  可 / v ,  分出 / v ,  「 / x ,  石墨烯 / x ,  」 / x ,  ; / x ,  此時 / c ,  又 / d ,  可以 / c ,  分出 / v ,  來 / zg ,  凱特琳 / nz ,  了 / ul ,  。 / x ,
========================================
easy_install/ /is/ /great
python/ /的/正则表达式/是/好用/的
========================================
今天天气/不错
今天天气 Before: 3, After: 0
今天/天气/不错
----------------------------------------
如果/放到/post/中将/出错/。
中将 Before: 763, After: 494
如果/放到/post/中/将/出错/。
----------------------------------------
我们/中/出/了/一个/叛徒
中出 Before: 3, After: 3
我们/中/出/了/一个/叛徒
----------------------------------------
result of  水果世博园
买<b class="match term0">水果</b>然后来<b class="match term1">世博园</b>
==========
result of  你
second one <b class="match term0">你</b> 中文测试中文 is even more interesting
==========
result of  first
<b class="match term0">first</b> document we’ve added
==========
result of  中文
second one 你 <b class="match term0">中文</b>测试<b class="match term0">中文</b> is even more interesting
==========
result of  交换机
干事每月经过下属科室都要亲口交代24口<b class="match term0">交换机</b>等技术性器件的安装工作
==========
result of  交换
咱俩<b class="match term0">交换</b>一下吧
干事每月经过下属科室都要亲口交代24口<b class="match term0">交换</b>机等技术性器件的安装工作
==========
我
好
朋友
是
李明
我
爱
北京
天安
天安门
ibm
microsoft
dream
intetest
interest
me
lot
result of  水果小姐
==========
result of  你
==========
result of  first
==========
result of  中文
==========
result of  交换机
==========
result of  交换
==========
result of  少林
==========
result of  乔峰
==========
EEE
======================================================================
ERROR: test_file (unittest.loader._FailedTest.test_file)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_file
Traceback (most recent call last):
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 396, in _find_test_path
    module = self._get_module_from_name(name)
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 339, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\test\test_file.py", line 7, in <module>
    url = sys.argv[1]
          ~~~~~~~~^^^
IndexError: list index out of range


======================================================================
ERROR: test_pos_file (unittest.loader._FailedTest.test_pos_file)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_pos_file
Traceback (most recent call last):
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 396, in _find_test_path
    module = self._get_module_from_name(name)
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 339, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\test\test_pos_file.py", line 9, in <module>
    url = sys.argv[1]
          ~~~~~~~~^^^
IndexError: list index out of range


======================================================================
ERROR: test_whoosh_file (unittest.loader._FailedTest.test_whoosh_file)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_whoosh_file
Traceback (most recent call last):
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 396, in _find_test_path
    module = self._get_module_from_name(name)
  File "C:\Users\sunwoo\scoop\apps\python\3.13.7\Lib\unittest\loader.py", line 339, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File "C:\Users\sunwoo\Documents\.GITHUB.3rd\jieba\test\test_whoosh_file.py", line 20, in <module>
    file_name = sys.argv[1]
                ~~~~~~~~^^^
IndexError: list index out of range


----------------------------------------------------------------------
Ran 3 tests in 0.001s

FAILED (errors=3)

While using `jieba`, printed the warning below.
replaced `pkg_resources` with `importlib.resources`
suppress deprecation warning

```
Lib\site-packages\jieba\_compat.py:18: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
```
environment used for commit `c13db831e3b156d0f724c6d4c56b91a48bcdf443`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant