2

I get an error when trying to import Tensorflow (v.2.2):

In order to make sure that there are no issues with the Tensorflow installation, I re-installed all the relevant packages in a virtual environment. The error stack that results is the following (both in the virtual and in the original environments)

ImportError: Traceback (most recent call last): File "C:\Anaconda\envs\cifar_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Anaconda\envs\cifar_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Anaconda\envs\cifar_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "c:\anaconda\lib\imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "c:\anaconda\lib\imp.py", line 343, in load_dynamic return _load(spec) ImportError: DLL load failed: The specified module could not be found. Failed to load the native TensorFlow runtime.

Is it possible to tell What DLL is failing to load exactly?

Edit:

If I downgrade to Tensorflow v2.0 the import doesn't fail, but all scripts need to be re-written

If I downgrade to Tensorflow v2.1, the import still fails.

It would be really helpful if somebody could point at what the issue might be.

2 Answers2

2

Downgrading to Tensorflow v1.13.1, which I am using in another machine, results in a collection of warnings, but no errors.

Ridiculous altogether

0

I had this issue and there didn't appear to be any smoking gun solution - none of them worked in isolation. For anyone truly desperate, this is what I did that cumulatively solved the issue. Note, I am working in an Anaconda Virtual Environment (venv):

  1. I ensured the C++ redistributable was correctly installed, as suggested by xdhmoore in the this related post. After uninstalling and reinstalling it, to be certain, I upgraded Visual Studio from 2019 to 2022.

  2. I updated Conda to the newest version.

  3. Thereafter, I created a wholly new venv. However, I did not use Conda to install any packages except the mandatory packages that it uses to create the environment. I then installed tensorflow using pip (and all other desired packages that I was having issues with pip as well).

  4. Due to this GitHub post, I copied msvcp140.dll from the System32 folder to my venv's DLL folder.

Thereafter, tensorflow works again.