taishi-i / nagisa

A Japanese tokenizer based on recurrent neural networks
https://huggingface.co/spaces/taishi-i/nagisa-demo
MIT License
379 stars 22 forks source link

AttributeError: module 'utils' has no attribute 'OOV' #14

Closed RonenHong closed 4 years ago

RonenHong commented 5 years ago

Hi, I got error in 'import nagisa' as below

OOV = utils.OOV AttributeError: module 'utils' has no attribute 'OOV'

I did 'pip install nagisa' on the conda envrionment python 3.7 and 3.6 I ran it on my Mac.

taishi-i commented 5 years ago

Hi @RonenHong, Thank you for using nagisa.

Does utils.py exist in the working directory? Since it exists in the working directory, I think that it is imported first and an error occurs. Could you rename utils.py into _datautils.py? I think that errors can be avoided by renaming.

RonenHong commented 5 years ago

My bad, that's the problem. I have my utils.py. Thank you so much

ssaikiran123 commented 4 years ago

Hello Team I am facing same problem as mentioned by @RonenHong and the issue because in prepro.py file we are using OOV = utils.OOV PAD = utils.PAD

taishi-i commented 4 years ago

Hi @ssaikiran123, Thank you for using nagisa.

The first thing I want to check is: Does utils.py exist in your working directory? Since it exists in the working directory, could you rename utils.py into data_utils.py? I guess that errors can be avoided by renaming.

ssaikiran123 commented 4 years ago

Yes i tried it by renaming but still facing same issue @taishi-i

ssaikiran123 commented 4 years ago

When i am trying to run the individual python file i.e init.py,model.prepro,tagger,train,utils for all same AttributeError: module 'utils' has no attribute 'OOV' Error: (image @taishi-i

taishi-i commented 4 years ago

Thank you for sharing your screenshot. You don't need to rename utils.py in nagisa-master/nagisa. Please download the repository again.

Assuming that you run python main.py, this AttributeError occurs when the working directory structure is as follows.

working/
├── utils.py
└── main.py

0 directories, 2 files

If utils.py exists in your working directory, could you rename utils.py into data_utils.py as follows?

working/
├── data_utils.py
└── main.py

0 directories, 2 files

If this does not resolve the error, could you share the error with the python file you ran?

ssaikiran123 commented 4 years ago

Hello @taishi-i thanks for your response , I didn't get this part Assuming that you run python main.py. As suggested i downloaded the repository again.I have checked there is no utils.py in my working directory . Please suggest me how do i check whether the utils.py exists in your working directory just for clarification.

Error : (base) D:\Nagisa code\nagisa-master>python "import nagisa.py" [dynet] random seed: 1234 [dynet] allocating memory: 32MB [dynet] memory allocation done. Traceback (most recent call last): File "import nagisa.py", line 1, in import nagisa File "D:\Nagisa code\nagisa-master\nagisa__init__.py", line 3, in from nagisa.train import fit File "D:\Nagisa code\nagisa-master\nagisa\train.py", line 12, in import prepro File "D:\Nagisa code\nagisa-master\nagisa\prepro.py", line 11, in OOV = utils.OOV AttributeError: module 'utils' has no attribute 'OOV'

C:\Users\SAIKIRAN

import nagisa [dynet] random seed: 1234 [dynet] allocating memory: 32MB [dynet] memory allocation done. Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa__init__.py", line 3, in from nagisa.train import fit File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\train.py", line 12, in import prepro File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\prepro.py", line 11, in OOV = utils.OOV AttributeError: module 'utils' has no attribute 'OOV'

taishi-i commented 4 years ago

Hi @ssaikiran123,

As far as the errors are concerned, the following two things seem to be the cause of the errors. 1) Running a python script (nagisa.py) in nagisa-master 2) Using the same file name (nagisa.py) as the library (nagisa)

Could you make a new directory (e.g, working) and rename your python script (nagisa.py -> main.py) as follows?

Before

nagisa-master/
└── nagisa.py
0 directories, 1 file

After

working/
└── main.py
0 directories, 1 file
ssaikiran123 commented 4 years ago

Hello @taishi-i as suggested i changed the folder names and nagisa_test.py to work_test.py but still facing the issue. (base) D:\working code\working\test>python Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. o Type "help", "copyright", "credits" or "license" for more information.

import nagisa [dynet] random seed: 1234 [dynet] allocating memory: 32MB [dynet] memory allocation done. Traceback (most recent call last): File "", line 1, in File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa__init__.py", line 3, in from nagisa.train import fit File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\train.py", line 12, in import prepro File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\prepro.py", line 11, in OOV = utils.OOV AttributeError: module 'utils' has no attribute 'OOV'

This is the directory now D:\working code\working\test I have pasted the folder in my anaconda 3-lib-site-packages too . (base) D:\working code>python main.py [dynet] random seed: 1234 [dynet] allocating memory: 32MB [dynet] memory allocation done. Traceback (most recent call last): File "main.py", line 1, in import nagisa File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa__init__.py", line 3, in from nagisa.train import fit File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\train.py", line 12, in import prepro File "C:\ProgramData\Anaconda3\lib\site-packages\nagisa\prepro.py", line 11, in OOV = utils.OOV AttributeError: module 'utils' has no attribute 'OOV'

taishi-i commented 4 years ago

Hi @ssaikiran123, I don't think there is any problem with your directory structure and the file name. Thank you for trying out my suggestions.

I want to have a check that nagisa is installed correctly. Could you try to uninstall it and reinstall it again?

Uninstall: pip uninstall nagisa Install: pip install nagisa

After pip install nagisa, did you get the following message?

Installing collected packages: nagisa
Successfully installed nagisa-0.2.6
ssaikiran123 commented 4 years ago

Hello @taishi-i i have trouble in pip installing nagisa so i am using this repository as other option ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

\Users\SAIKIRAN>pip3 install --user nagisa llecting nagisa Using cached https://files.pythonhosted.org/packages/d0/53/deb6b48924f1e3bd8d5932c4738cb23e71143c120831531619371c816d45/nagisa-0.2.6.tar.gz ERROR: Command errored out with exit status 1: command: 'c:\users\saikiran\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\SAIKIRAN\AppData\ ocal\Temp\pip-install-tligo0t9\nagisa\setup.py'"'"'; file='"'"'C:\Users\SAIKIRAN\AppData\Local\Temp\pip-install-tligo0t9\nagisa\setup.py'"'"';f=getattr( kenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base ip-egg-info cwd: C:\Users\SAIKIRAN\AppData\Local\Temp\pip-install-tligo0t9\nagisa\ Complete output (95 lines): Processing numpy/random_bounded_integers.pxd.in Processing numpy/random\bit_generator.pyx Traceback (most recent call last): File "C:\Users\SAIKIRAN\AppData\Local\Temp\easy_install-avuzwlyq\numpy-1.19.0rc2\tools\cythonize.py", line 59, in process_pyx from Cython.Compiler.Version import version as cython_version ModuleNotFoundError: No module named 'Cython'

taishi-i commented 4 years ago

Hi @ssaikiran123, Cython does not seem to be installed. Before installing nagisa, could you install cython library?

pip install --upgrade cython
pip install nagisa
ssaikiran123 commented 4 years ago

Hello Taishi-I/Nagisa

I Have installed cython but still facing issue in pip installing nagisa. I request you to please help me on this. ERROR: Command errored out with exit status 1: command: 'c:\users\saikiran\appdata\local\programs\python\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] =

Thanks & Regards Saikiran 8971647885

On Wed, Jun 17, 2020, 21:47 taishi-i notifications@github.com wrote:

Hi @ssaikiran123 https://github.com/ssaikiran123, Cython does not seem to be installed. Before installing nagisa, could you install cython library?

pip install --upgrade cython pip install nagisa

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/taishi-i/nagisa/issues/14#issuecomment-645449232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOFNN5UU7ZLMXKFU73XCDETRXDUBFANCNFSM4HORK26A .

taishi-i commented 4 years ago

Hi @ssaikiran123, I think it's probably due to not installing the library correctly. As it is not related to this issue (#14 AttributeError), could you create a new issue? So let's discuss the Installation problems there. I will close this issue.