daniel-kukiela / nmt-chatbot

NMT Chatbot
GNU General Public License v3.0
385 stars 212 forks source link

Cannot make prepare_data.py working. Error code is AttributeError: __exit__ {Please help me} #155

Closed kobrata6 closed 4 years ago

kobrata6 commented 4 years ago
Preparing training set from raw set
File: tst2012.to
Traceback (most recent call last):
  File "prepare_data.py", line 565, in <module>
    prepare()
  File "prepare_data.py", line 77, in prepare
    with Pool(processes=preprocessing['cpu_count']) as pool:
AttributeError: __exit__

This is the code I receive in the terminal

This is lane 77: with Pool(processes=preprocessing['cpu_count']) as pool:

Nathan-Chell commented 4 years ago

Did you change anything in prepare data?

Nathan-Chell commented 4 years ago

Also, you have to make sure you are using python 3. Python 2 doesn't support 'with' I believe.

kobrata6 commented 4 years ago

Did you change anything in prepare data?

Yes, at the line # Output file handler out_file = open('{}{}'.format(preprocessing['train_folder'], file_name), 'w', encoding='utf-8', buffering=131072) I removed ""encoding='utf-8', because in the terminal I am getting error Preparing training set from raw set File: tst2012.to Traceback (most recent call last): File "prepare_data.py", line 565, in <module> prepare() File "prepare_data.py", line 65, in prepare out_file = open('{}{}'.format(preprocessing['train_folder'], file_name), 'w', encoding='utf-8', buffering=131072) TypeError: file() takes at most 3 arguments (4 given)


Okay I run the file using Python3 (thanks for that mate) and I got new error: Preparing training set from raw set File: train.from Traceback (most recent call last): File "prepare_data.py", line 565, in <module> prepare() File "prepare_data.py", line 80, in prepare number_of_records = min(amount, sum(1 for _ in open_function(source_file_name, 'rt', encoding='utf-8', **additioan_params))) UnboundLocalError: local variable 'open_function' referenced before assignment What should i do?

Nathan-Chell commented 4 years ago

I'd start up a VM and install everything from scratch if I were you.

kobrata6 commented 4 years ago

I'd start up a VM and install everything from scratch if I were you.

That is what I did and here I am