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 'utils' has no attribute 'OOV' #14

Closed
RonenHong opened this issue May 22, 2019 · 15 comments
Closed

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

RonenHong opened this issue May 22, 2019 · 15 comments

Comments

@RonenHong
Copy link

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
Copy link
Owner

taishi-i commented May 22, 2019

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 data_utils.py? I think that errors can be avoided by renaming.

@RonenHong
Copy link
Author

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

@ssaikiran123
Copy link

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
Copy link
Owner

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.

@taishi-i taishi-i reopened this Jun 16, 2020
@ssaikiran123
Copy link

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

@ssaikiran123
Copy link

ssaikiran123 commented Jun 16, 2020

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
Copy link
Owner

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
Copy link

ssaikiran123 commented Jun 16, 2020

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
Copy link
Owner

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
Copy link

ssaikiran123 commented Jun 17, 2020

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
Copy link
Owner

taishi-i commented Jun 17, 2020

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
Copy link

ssaikiran123 commented Jun 17, 2020

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
Copy link
Owner

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
Copy link

ssaikiran123 commented Jun 17, 2020 via email

@taishi-i
Copy link
Owner

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.

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

3 participants