Ask questionsTensorflow 2.0 error when used via pyinstaller build - ImportError: cannot import name 'pywrap_tensorflow' from 'tensorflow_core.python'

<em>Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template</em>

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version: 2.0
  • Python version: 3.7
  • Installed using virtualenv? pip? conda?: pip
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Describe the problem This has happened after upgrade to Tensorflow 2.0 .

On executing the EXE file generated by Pyinstaller for Tensorflow 2.0, we get the following error:

'ImportError: cannot import name 'pywrap_tensorflow' from 'tensorflow_core.python'

The scripts work okay in PyCharm or Jupyter. The same version of scripts when run under Tensorflow 1.x execute correctly

Provide the exact sequence of commands / steps that you executed before running into the problem

  1. upgraded tensorflow to 2.0
  2. Adjusted python code to accommodate module dependence from Keras to tf.keras
  3. Build exe --onefile via pyinstaller
  4. on execution of exe get the following error "ImportError: cannot import name 'pywrap_tensorflow' from 'tensorflow_core.python' "

Any other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.


Answer questions oanush

@anilkdas , Can you please refer this link of similar issue ?Thanks!


Related questions

Error occurred when finalizing GeneratorDataset iterator hot 4
The flag 'log_dir' is defined twice. hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
Incorrect Error TypeError: padded_batch() missing 1 required positional argument: &#39;padded_shapes&#39; hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
tf.strings.split bug hot 2
Cannot run tensorflow GPU 2.0 with cuda 9.2 hot 2
module 'tensorflow_core._api.v2.nn' has no attribute 'rnn_cell' hot 2
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 2
compiling c++ code with TFLite library gives error with cstring hot 2
ModuleNotFoundError: No module named 'tensorflow.contrib' hot 2
TF2.0 AutoGraph issue hot 2
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(7, 7, 3, 64), dtype=float32) is not an element of this graph. hot 2
Github User Rank List