2
votes

I ran through the TensorFlow object detection installation on Windows.

https://medium.com/riow/tensorflow-object-detection-on-windows-ad10bfde217c

After successfully installing TensorFlow object detection,

I ran following command to test, and receiving error below. How can this be fixed?

python object_detection/builders/model_builder_test.py

Error: Traceback (most recent call last): File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed while importing pywrap_tensorflow_internal: The specified module could not be found. Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 21, in from object_detection.builders import model_builder File "c:\testimage\models\research\object_detection\builders\model_builder.py", line 23, in from object_detection.builders import anchor_generator_builder File "c:\testimage\models\research\object_detection\builders\anchor_generator_builder.py", line 23, in from object_detection.anchor_generators import flexible_grid_anchor_generator File "c:\testimage\models\research\object_detection\anchor_generators\flexible_grid_anchor_generator.py", line 17, in import tensorflow.compat.v1 as tf File "C:\TestImage\models\venv\lib\site-packages\tensorflow_init.py", line 41, in from tensorflow.python.tools import module_util as module_util File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python_init.py", line 40, in from tensorflow.python.eager import context File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\eager\context.py", line 35, in from tensorflow.python import pywrap_tfe File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in from tensorflow.python import pywrap_tensorflow File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.

Currently using Python 3.8 with latest tensorflow, with tensorflow-cpu

1
Idk. I do seem to have both a /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/pywrap_tensorflow.py file and a /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/pywrap_tensorflow_internal.py. Best I can tell, your error is coming from the first, while looking for the second? It also looks like one or both of these are generated from something called SWIG, which I guess generates python interfaces to C/C++ classes? This looks relevant.xdhmoore
Maybe your tensorflow didn't install correctly. Did you get any errors there? This also looks relevantxdhmoore
Again, to link to link back to the tensorflow install instructions, there is listed a requirement there for the visual C++ redistributable, which based on the above two SO posts sounds related. Could that be it?xdhmoore
interesting, yeah, I already installed the C++ package, so not sure, I will keep lookingmattsmith5
Here's another stab in the dark: if you installed TF w/o the C++ package and then reinstalled TF, or if you installed the C++ package afterwards, it wouldn't surprise me if TF needs that C++ package at TF install time (based on a glance at the missing module) so that it can generate the module then, for whatever that speculation is worth...xdhmoore

1 Answers

1
votes

tldr;

You need to install the C++ redistributable mentioned on the install page before installing TensorFlow so that TensorFlow can use it to generate code at install time.

Details:

I'm not an expert but it sounds like this was key:

The pywrap_tensorflow_internal.py module you are missing appears to me to be a SWIG-generated python interface to a C++ library, or something of that nature. My guess is, that file gets generated when you install TensorFlow (it reminds me of how some Ruby gems have to compile C++ when you install them, for whatever that's worth). Since you don't have that generated file, my guess is that the C++ package mentioned on the TensorFlow install page is needed for that code generation, so you need to have the C++ package installed before installing TensorFlow.

Totally a guess, but perhaps you installed the C++ package after TF. In that case, you should be able to uninstall TF, install the C++ package, and then install TF again.

Maybe a lingering question is if there were any indicative error messages on installing TF about the missing C++ package and if not, maybe there should be.