Import error of tensorflow package-ImportError: DLL load failed: Cannot find the specified module


Preface

After resetting the tensorfolw environment in Anaconda Prompt, an error was reported when importing the package.


1. Run error

Execute import package command

import tensorflow as tf

The error display is as follows: The
Report an error
specified module cannot be found, so try to solve it. The following is a long history of resolution.

2. Reasons and solutions

1. Version reason

It may be caused by the version. tensorflow needs the support of 64-bit python. When I installed it in my laptop, I kept reporting this error because I installed a 32-bit python compiler.
Because of the newly reinstalled Anaconda, the download is indeed 64bit, so we can rule out this reason.

2. Spyder is not installed in Anaconda

This is one of the reasons I found the most repetitive. The solution is to open tensorflow in Anaconda Prompt and enter the following command to install Spyder

conda install spyder

After the installation is complete, I enter the import command, but an error is still reported, next.

3.Python does not correspond

The Python in Anaconda installed on the machine is version 3.8, but the version installed in the tensorflow environment is 3.5.x, so I uninstalled the original Python again and changed the 3.5 in the following command to 3.8. After the operation, an error will still be reported.

conda create --name tensorflow python=3.5

4. The installed version of tensorflow is too high

During the reinstallation process, an error was reported when installing tensorflow using the following command. The error reported that it could not find the tensorflow that conforms to the version (forgot to take the screenshot), and there are only many 2.0 versions.

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.5.0

After many searches, I found some low-version tensorflow download addresses, and used the command to replace the source URL, still doing useless work, so I used the following command to install the new version directly.

pip install --upgrade --ignore-installed tensorflow

Some information found on the Internet said that the new version of tensorflow does not support older hosts. Looking at the older hosts in the lab, I focused on this step. It took a lot of time, but all failed. Next.

5. Install the new version of Vc

Some information on the Internet said that it was caused by the insufficient Vc version on the machine. Because this step requires downloading a larger installation package and not enough to convince me, the authenticity is yet to be determined, so I did not try.

6. Incomplete environment (solved)

For the new version of tensorflow, a msvcp140_1.dll file is required, and a vc_redist application needs to be downloaded.
The download address is as follows:
https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads
Download the file pointed to by the arrow. After downloading, run it to solve the problem.
download
Re-enter the virtual environment to open Python, enter the code for importing the package, and the package can be successfully imported.
success


to sum up

For this Anaconda and tensorflow environment, which has been reinstalled many times before and after the error, it took a whole night, but as long as I persisted, as long as I stepped on enough pits, I can step on it!

Guess you like

Origin blog.csdn.net/weixin_47585015/article/details/110358232