Search code examples
python-2.7tensorflowsyntaxnet

training SyntaxNet from parser_trainer_test.sh (ImportError: cannot import name tf_logging)


I am new to python and SyntaxNet and I am trying to train SyntaxNet from SyntaxNet Tutorial. To trained the model I updated parser_trainer_test.sh based on The Tutorial. and ran it as follow:

ubuntu@ubuntu-VirtualBox:~/models/syntaxnet$ syntaxnet/parser_trainer_test.sh

It gave me this error:

syntaxnet/parser_trainer_test.sh: line 36: /home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer: No such file or directory

Then I updated "$BINDIR/parser_trainer" \ in line 35 of parser_trainer_test.sh to "$BINDIR/parser_trainer.py" \ and ran it again.

And it gave me this error:

File "/home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer.py", line 25,in <module>
from tensorflow.python.platform import tf_logging as logging
ImportError: cannot import name tf_logging

I went through tf_logging.py and all other python files in syntaxnet/tensorflow/python/platform I think that's where the error is. But if you want, I can post more.

parser.trainer.py :

import os
import os.path
import time

import tensorflow as tf
from tensorflow.python.platform import tf_logging as logging # this is where error happens
from tensorflow.python.platform import gfile

tf_logging.py:

import logging
import os
import sys
import time
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN   

There is something that I am suspecious about (I am not perofessional so sorry if it seems silly). I found a file named logging.hin path tensorflow/tensorflow/core/platform which defines DEBUG,ERROR,FATAL,.. and I get confused whether the aim of the model is the logging package from python or this logging.h file. If am wrong, which is probable, please help me through this problem.


Solution

  • I suspect the problem is that you are trying to run the script directly, and it expects to be invoked by Bazel (so that the environment, paths, etc. are set up appropriately). Try the following command instead:

    $ bazel test //syntaxnet:parser_trainer_test