1

I have tensorflow 1.5 and everything is working fine with tensorflow. Now i want to convert my tensorflow keras model to be used in web app so i installed tensorflowjs successfully but when i import i get the error.

I have tried changing the following versions:
numpy from 1.16.4 to 1.15.1,
tensorflow 1.5.0 to 1.8.0 and 1.12.0,
tensorflowjs 1.1.2 to 1.0.0

tensorflow test:

import tensorflow as tf

print(tf.__version__)
hello = tf.constant("Hello Tensorflow")
with tf.Session() as sesh:
    print(sesh.run(hello))

Output:

1.12.0
2019-06-11 12:02:11.140827: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
b'Hello Tensorflow'

So i guess everything is fine with tensorflow but still i cant import tensorflowjs due to some files missing in my tensorflow installation.

i got this error first:

Traceback (most recent call last):
  File "C:/Users/Uxama/PycharmProjects/untitled1/test.py", line 2, in <module>
    import tensorflowjs as tfjs
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\__init__.py", line 21, in <module>
    from tensorflowjs import converters
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\converters\__init__.py", line 24, in <module>
    from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 29, in <module>
    from tensorflow.python.framework import convert_to_constants
ImportError: cannot import name 'convert_to_constants'

Then i placed the file (convert_to_constants) manually because changing the versions doesn't seems to work and change anything.

Then i got this error:

Traceback (most recent call last):
  File "C:/Users/Uxama/PycharmProjects/untitled1/test.py", line 2, in <module>
    import tensorflowjs as tfjs
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\__init__.py", line 21, in <module>
    from tensorflowjs import converters
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\converters\__init__.py", line 24, in <module>
    from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 29, in <module>
    from tensorflow.python.framework import convert_to_constants
  File "C:\Users\Uxama\PycharmProjects\untitled1\venv\lib\site-packages\tensorflow\python\framework\convert_to_constants.py", line 26, in <module>
    from tensorflow.python.eager import wrap_function
ImportError: cannot import name 'wrap_function'

I did the same thing again and placed the file but the errors seems to kept coming.

I don't know what exactly causing the problem i installed tensorflow with pip and also tried installing it with wheels as well. I just want to successfully install tensorflowjs so that i can convert my keras model to use in web app.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
DevPy
  • 234
  • 4
  • 16

1 Answers1

1

Tensorflow 1.12 doesn't define a function called wrap_function(). Consider upgrading to API r1.13. Here are the functions defined in API r1.12, which you are currently using, and here is the wrap_function() method which is defined in API r1.13.

Vishnu Dasu
  • 533
  • 5
  • 18
  • After upgrading to tensorflow1.13.1 i get this error: ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' ImportError: numpy.core.multiarray failed to import The above exception was the direct cause of the following exception: Traceback (most recent call last): File "", line 968, in _find_and_load SystemError: returned a result with an error set ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import – DevPy Jun 11 '19 at 09:56
  • Please upgrade your `numpy` version to `1.16.1`. – Vishnu Dasu Jun 11 '19 at 10:01
  • Thanks for your suggestions tensorflow is working fine also i converted the model with tensorflowjs after i upgraded to numpy 1.16.1 but i wonder if that would cause any problem with tensorflowjs because of this warning that i get when i installed numpy 1.16.1 ==> tensorflowjs 1.1.2 has requirement numpy==1.15.1, but you'll have numpy 1.16.1 which is incompatible. – DevPy Jun 11 '19 at 10:27
  • 1
    I'm not sure but I think you can ignore the warning. A similar issue has been discussed [here](https://github.com/tensorflow/tfjs/issues/1484). – Vishnu Dasu Jun 11 '19 at 10:34