Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Possible solutions of Unittest error for Windows installation #334

Open
pliu19 opened this issue Aug 31, 2018 · 2 comments
Open

Possible solutions of Unittest error for Windows installation #334

pliu19 opened this issue Aug 31, 2018 · 2 comments

Comments

@pliu19
Copy link

pliu19 commented Aug 31, 2018

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.

@flycsuu
Copy link

flycsuu commented Sep 19, 2018

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]

@Aeryltic
Copy link

Aeryltic commented Nov 30, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants