google / seq2seq

A general-purpose encoder-decoder framework for Tensorflow

Home Page:https://google.github.io/seq2seq/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible solutions of Unittest error for Windows installation

pliu19 opened this issue · comments

I hope this could resolve your painful errors but credits are from all the previous discussion and other resources.

When installing on Windows, I'm encountering three errors. I will share my experience one by one.

  1. bernoulli error

     It's well explained in #285. You need to modify 4 lines in helper.py. 
    
  2. permission error

     I think this is due to Windows permission feature. 
     Solution is tricky (I don't know why...). 
     In the /metrics/bleu.py, you need to modify the code in line 72 and line 79.  
     line 72 (change the variable into your any local file):
     with open(“D:\test.txt”, “r”) as read_pred: 
     line 79:
     bleu_out = subprocess.check_output(bleu_cmd, 
       stdin=hypothesis_file, stderr=subprocess.STDOUT)
    
  3. OSError: [WinError 193] %1 error

     a. install perl for windows
     b. Modify the code in bleu.py in line 73 (one line into two lines)
     bleu_cmd = [‘perl’] 
     bleu_cmd += [multi_bleu_path] 
    

Then type

    python -m unittest seq2seq.test.pipeline_test

I wish you could see 'OK' after all the logs in the end.

OSError: [WinError 193] %1 error

 a. install perl for windows
 b. Modify the code in bleu.py in line 73 (one line into two lines)
 bleu_cmd = [‘perl’] 
 bleu_cmd += [multi_bleu_path]

Your solution for permission error didn't quite work for me, but I did the following changes instead and got "OK" in the end:
a. modify 2 lines

line 62: hypothesis_file = tempfile.NamedTemporaryFile(delete=False)
line 66: reference_file = tempfile.NamedTemporaryFile(delete=False)

b. move lines 90 and 91 before line 72 so it looks like this:

...
  reference_file.flush()

  # Close temp files
  hypothesis_file.close()
  reference_file.close()

  # Calculate BLEU using multi-bleu script
  with open(hypothesis_file.name, "r") as read_pred:
...

c. I don't know why, but I had to restart my terminal and venv - when I first made those changes it still didn't work, but after a restart it did, so...

For the reference see: https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile