Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'xmnlp' has no attribute 'set_model' #41

Closed
xyz-hcy opened this issue Apr 17, 2022 · 6 comments
Closed

AttributeError: module 'xmnlp' has no attribute 'set_model' #41

xyz-hcy opened this issue Apr 17, 2022 · 6 comments

Comments

@xyz-hcy
Copy link

xyz-hcy commented Apr 17, 2022

您好,通过方式二配置模型:xmnlp.set_model('/path/to/xmnlp-models')
报错:AttributeError: module 'xmnlp' has no attribute 'set_model'
如何解决?

@SeanLee97
Copy link
Owner

hi @xyz-hcy , 可否提供 xmnlp 的版本,我在最新版本下测试是没问题的

Python 3.7.3 (default, Oct 31 2020, 00:05:10)
[Clang 12.0.0 (clang-1200.0.32.21)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmnlp
>>> xmnlp.__version__
'0.5.1'
>>> xmnlp.set_model("/Users/seanlee/Workspace/xmnlp/xmnlp/xmnlp-onnx-models")

@xyz-hcy
Copy link
Author

xyz-hcy commented Apr 18, 2022

感谢您的回复!我这边找到模块内定义的所有名称存在问题(重复下载未解决):

Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmnlp
>>> dir(xmnlp)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'np', 'xmnlp']
>>> 

@SeanLee97
Copy link
Owner

可能装了多个版本,可以试试把所有的 xmnlp 版本都卸载了,再重新安装

@xyz-hcy
Copy link
Author

xyz-hcy commented Apr 18, 2022

谢谢您及时的回复!这边还是有个问题
在Linux直接输入python,运行dir(xmnlp)无异常:

(wenet) root@ubuntu-522:$ python
Python 3.6.15 | packaged by conda-forge | (default, Dec  3 2021, 18:49:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
  import xmnlp
  dir(xmnlp)
['List', 'Optional', 'Tokenization', 'Tuple', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_checker', '_pinyin', '_radical', '_sentiment', 'base_model', 'checker', 'config', 'deep_seg', 'deep_tag', 'fast_seg', 'fast_tag', 'fast_tokenizer', 'keyphrase', 'keyword', 'lexical', 'load_stopword', 'module', 'ner', 'pinyin', 'radical', 'seg', 'sentiment', 'set_model', 'set_stopword', 'summary', 'tag', 'tokenizer', 'utils']
  exit()

在运行python文件时出错:

(wenet) root@ubuntu-522:~$ python xmnlp.py
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'np', 'xmnlp']

@SeanLee97
Copy link
Owner

@xyz-hcy 你是不是在当前路径新建了一个 xmnlp.py 文件呢? 如果是的话把这个文件重命名下,比如改成 xmnlp_demo.py 试试。因为当前目录有重名文件的话 import 时会优先 import 当前目录的文件。

@xyz-hcy
Copy link
Author

xyz-hcy commented Apr 20, 2022

好的谢谢!问题解决了!

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

No branches or pull requests

2 participants