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

Tokenizer: OSError: [Errno 2] No such file or directory #46

Open
rubencart opened this issue Apr 14, 2019 · 4 comments
Open

Tokenizer: OSError: [Errno 2] No such file or directory #46

rubencart opened this issue Apr 14, 2019 · 4 comments

Comments

@rubencart
Copy link

Like in #22 (comment) , I got

OSError: [Errno 2] No such file or directory: 'java'

When running the evaluation, even with java definitely installed. This SO discusses it: https://stackoverflow.com/a/55675914/2332296. I was able to solve it by setting shell=True and making cmd in

p_tokenizer = subprocess.Popen(cmd, cwd=path_to_jar_dirname, stdout=subprocess.PIPE, shell=True)

from

cmd = ['java', '-cp', 'stanford-corenlp-3.4.1.jar', 'edu.stanford.nlp.process.PTBTokenizer', '-preserveLines', '-lowerCase', 'tmpWS5p0Z']

(where 'tmpWS5p0Z' is the name of the tempfile.NamedTemporaryFile that is added), into:

cmd = ['/abs/path/to/java -cp /abs/path/to/stanford-corenlp-3.4.1.jar edu.stanford.nlp.process.PTBTokenizer -preserveLines -lowerCase /abs/path/to/temporary_file']
@JunlongFeng
Copy link

JunlongFeng commented May 10, 2019

I solved this error, by using absolute path in sys.path.append() to include the coco-caption file .
I still get this error running in Pycharm,but it works well by using terminal command

@ynuwm
Copy link

ynuwm commented Jun 27, 2019

@rubencart
hi, how can I get the name of 'tmpWS5p0Z' according to your answer.

@rubencart
Copy link
Author

@ynuwm that is automatically added by the line cmd.append(os.path.join(path_to_jar_dirname, os.path.basename(tmp_file.name))). Just change that line into cmd[0] += os.path.join(path_to_jar_dirname, os.path.basename(tmp_file.name))

@ynuwm
Copy link

ynuwm commented Jun 27, 2019

ok, I get it, thank you very much.

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