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 'distutils' has no attribute 'util' #87

Closed
w2781993753 opened this issue Dec 26, 2017 · 10 comments
Closed

AttributeError: module 'distutils' has no attribute 'util' #87

w2781993753 opened this issue Dec 26, 2017 · 10 comments

Comments

@w2781993753
Copy link

File "main.py", line 250, in
main()
File "main.py", line 245, in main
nn = NeuroNER(**arguments)
File "/home/server1/share/NeuroNER-master/src/neuroner.py", line 257, in init
parameters, conf_parameters = self._load_parameters(arguments['parameters_filepath'], arguments=arguments)
File "/home/server1/share/NeuroNER-master/src/neuroner.py", line 118, in _load_parameters
parameters[k] = distutils.util.strtobool(v)
AttributeError: module 'distutils' has no attribute 'util'
Exception ignored in: <bound method NeuroNER.del of <neuroner.NeuroNER object at 0x7fb8d35fcda0>>
Traceback (most recent call last):
File "/home/server1/share/NeuroNER-master/src/neuroner.py", line 489, in del
self.sess.close()
AttributeError: 'NeuroNER' object has no attribute 'sess'

@ErwanPigneul
Copy link

hello,

add
from distutils import util

in main.py

@JohnGiorgi
Copy link
Contributor

Asked & answered in #75.

@bluesea0
Copy link

bluesea0 commented Apr 6, 2019

Sorry to bother again.
When I run

neuroner --train_model=False --use_pretrained_model=True --dataset_text_folder=./data/example_unannotated_texts --pretrained_model_folder=./trained_models/conll_2003_en

It shows the same error.

{'maximum_number_of_epochs': 100, 'tagging_format': 'bioes', 'load_all_pretrained_token_embeddings': False, 'number_of_gpus': 0, 'verbose': 0, 'reload_character_lstm': 1, 'optimizer': 'sgd', 'learning_rate': 0.005, 'pretrained_model_folder': './trained_models/conll_2003_en', 'character_lstm_hidden_state_dimension': 25, 'check_for_digits_replaced_with_zeros': 1, 'token_lstm_hidden_state_dimension': 100, 'patience': 10, 'gradient_clipping_value': 5.0, 'reload_character_embeddings': 1, 'token_embedding_dimension': 100, 'freeze_token_embeddings': 0, 'number_of_cpu_threads': 8, 'check_for_lowercase': 1, 'train_model': 0, 'use_character_lstm': 1, 'tokenizer': 'spacy', 'dataset_text_folder': './data/example_unannotated_texts', 'reload_feedforward': 1, 'character_embedding_dimension': 25, 'output_folder': './output', 'dropout_rate': 0.5, 'use_crf': 1, 'token_pretrained_embedding_filepath': './data/word_vectors/glove.6B.100d.txt', 'remap_unknown_tokens_to_unk': 1, 'reload_token_lstm': 1, 'fetch_trained_model': '', 'spacylanguage': 'en', 'debug': 0, 'parameters_filepath': './parameters.ini', 'load_only_pretrained_token_embeddings': 0, 'fetch_data': '', 'plot_format': 'pdf', 'reload_token_embeddings': 1, 'main_evaluation_mode': 'conll', 'experiment_name': 'experiment', 'reload_crf': 1, 'use_pretrained_model': 1} Checking compatibility between CONLL and BRAT for deploy_spacy set ... Done. Checking validity of CONLL BIOES format... Done. Traceback (most recent call last): File "/usr/local/bin/neuroner", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.5/dist-packages/neuroner/__main__.py", line 110, in main nn = neuromodel.NeuroNER(**arguments) File "/usr/local/lib/python3.5/dist-packages/neuroner/neuromodel.py", line 459, in __init__ self._check_param_compatibility(self.parameters, self.dataset_filepaths) File "/usr/local/lib/python3.5/dist-packages/neuroner/neuromodel.py", line 588, in _check_param_compatibility check_param_compatibility(parameters, dataset_filepaths) File "/usr/local/lib/python3.5/dist-packages/neuroner/neuromodel.py", line 394, in check_param_compatibility if parameters['output_scores'] and parameters['use_crf']: KeyError: 'output_scores' Exception ignored in: <bound method NeuroNER.__del__ of <neuroner.neuromodel.NeuroNER object at 0x7efddcb5ae10>> Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/neuroner/neuromodel.py", line 821, in __del__ self.sess.close() AttributeError: 'NeuroNER' object has no attribute 'sess'

First, I saw the reply in #75 . But when I open the neuromodel.py, there is already import distutils.util
Then I tried the reply in #62 . It still didn't work.
Last, I tried the reply in #87. Add from distutils import util to main.py. There's the same error.
So I don't konw how to solve the problem.
Is there any possible solution to it?

@tompollard
Copy link
Collaborator

I'm sorry @huanting74, your error relates to a recent update (#141) for optionally displaying scores in the output files. I'll look into this after the weekend.

In the meantime please could you check that you are using the latest version (1.0.6) of neuroner (pip install pyneuroner --upgrade).

If there is a mismatch between your neuroner version and your parameter file, then I would expect a key error (if parameters['output_scores'] and parameters['use_crf']: KeyError: 'output_scores').

We should add a version check to the package to avoid this problem.

@bluesea0
Copy link

bluesea0 commented Apr 7, 2019

I tried to upgrade the version of neuroner. It shows it is the latest version.

Requirement already up-to-date: pyneuroner in /usr/local/lib/python3.5/dist-packages (1.0.6)
Requirement already satisfied, skipping upgrade: scipy>=1.2.0 in /usr/local/lib/python3.5/dist-packages (from pyneuroner) (1.2.1)
..........

@tompollard
Copy link
Collaborator

@huanting74 adding the following line to your parameters.ini file may fix the issue for now:

output_scores = False

@gui-li
Copy link

gui-li commented Aug 8, 2019

My environment:
python 3.6.9
tensorflow 1.13.1
pyneuroner 1.0.7
parameters.ini cloned from commit 9347dbc

When I tried the command "neuroner --maximum_number_of_epochs=2 --token_pretrained_embedding_filepath=""" in the readme, it aborted with error below:

{'character_embedding_dimension': 25,
'character_lstm_hidden_state_dimension': 25,
'check_for_digits_replaced_with_zeros': 1,
'check_for_lowercase': 1,
'dataset_text_folder': './data/conll2003/en',
'debug': 0,
'dropout_rate': 0.5,
'experiment_name': 'test',
'fetch_data': '',
'fetch_trained_model': '',
'freeze_token_embeddings': 0,
'gradient_clipping_value': 5.0,
'learning_rate': 0.005,
'load_all_pretrained_token_embeddings': 'False',
'load_only_pretrained_token_embeddings': 0,
'main_evaluation_mode': 'conll',
'maximum_number_of_epochs': 2,
'number_of_cpu_threads': 8,
'number_of_gpus': 0,
'optimizer': 'sgd',
'output_folder': './output',
'output_scores': 0,
'parameters_filepath': './parameters.ini',
'patience': 10,
'plot_format': 'pdf',
'pretrained_model_folder': './trained_models/conll_2003_en',
'reload_character_embeddings': 1,
'reload_character_lstm': 1,
'reload_crf': 1,
'reload_feedforward': 1,
'reload_token_embeddings': 1,
'reload_token_lstm': 1,
'remap_unknown_tokens_to_unk': 1,
'spacylanguage': 'en',
'tagging_format': 'bioes',
'token_embedding_dimension': 100,
'token_lstm_hidden_state_dimension': 1,
'token_pretrained_embedding_filepath': '',
'tokenizer': 'spacy',
'train_model': 1,
'use_character_lstm': 1,
'use_crf': 1,
'use_pretrained_model': 0,
'verbose': 0}
Checking the validity of BRAT-formatted train set... Traceback (most recent call last):
File "c:\users*\anaconda3\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "c:\users*\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users*\Anaconda3\Scripts\neuroner.exe_main
.py", line 9, in
File "c:\users*\anaconda3\lib\site-packages\neuroner_main
.py", line 109, in main
nn = neuromodel.NeuroNER(**arguments)
File "c:\users*\anaconda3\lib\site-packages\neuroner\neuromodel.py", line 460, in init
self.dataset_filepaths, self.dataset_brat_folders = self._get_valid_dataset_filepaths(self.parameters)
File "c:\users*\anaconda3\lib\site-packages\neuroner\neuromodel.py", line 536, in _get_valid_dataset_filepaths
brat_to_conll.check_brat_annotation_and_text_compatibility(dataset_brat_folders[dataset_type])
File "c:\users*\anaconda3\lib\site-packages\neuroner\brat_to_conll.py", line 117, in check_brat_annotation_and_text_compatibility
raise IOError("Annotation file does not exist: {0}".format(annotation_filepath))
OSError: Annotation file does not exist: ./data/conll2003/en\train\train_text_00248.ann
Exception ignored in: <bound method NeuroNER.del of <neuroner.neuromodel.NeuroNER object at 0x000002104A64CAC8>>
Traceback (most recent call last):
File "c:\users*\anaconda3\lib\site-packages\neuroner\neuromodel.py", line 823, in del
self.sess.close()
AttributeError: 'NeuroNER' object has no attribute 'sess'

However, I tried adding output_scores = False in the parameters.ini file, still got the same error.

@Prachi0203
Copy link

I am able to see the output of the model in output folder/2021-10-09.../000_deploy.txt, but I am not able to understand of which text file it is showing the output. In ./data/example_unannotated_texts there are few files that are news.txt and news.ann (what is this file it is empty?) similarly there are some_random_text.txt and some_random_text.ann, but the result does not match any of it. I am confused. I want to test neuroner on my sentences. I am unable to find where to add so that I can get the output. I am using a pretrained model. Can anyone can help?

@Prachi0203
Copy link

When I try to change the text of news.txt I get the same error
AttributeError: 'NeuroNER' object has no attribute 'sess'

I tried updating neuroner , output_scores = False
but none of it worked

@Prachi0203
Copy link

how can I test neuro ner on my text data. If anyone know Please help? @tompollard

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

7 participants