question

Rostyslav-5394 avatar image
0 Votes"
Rostyslav-5394 asked Rostyslav-5394 answered

ImportError: Could not find the DLL(s) 'msvcp140_1.dll'.

Hello,

I am having a problem with the DLL files in VS Code.
When I do

 import tensorflow

I receive an error message, which says

 Traceback (most recent call last):
   File "c:\Users\Rostyslav\Git\study\study.py", line 5, in <module>
     import tensorflow
   File "C:\Users\Rostyslav\anaconda3\envs\hiwi-kt\lib\site-packages\tensorflow\__init__.py", line 41, in
 <module>
   File "C:\Users\Rostyslav\anaconda3\envs\hiwi-kt\lib\site-packages\tensorflow\python\__init__.py", line
 50, in <module>
     from tensorflow.python import pywrap_tensorflow
   File "C:\Users\Rostyslav\anaconda3\envs\hiwi-kt\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
     self_check.preload_check()
   File "C:\Users\Rostyslav\anaconda3\envs\hiwi-kt\lib\site-packages\tensorflow\python\platform\self_check.py", line 53, in preload_check
     raise ImportError(
 ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

I have downloaded and installed VC_redist.x64.exe as indicated by the message as you may also see in the screenshot below

![119020-image.png

In my environment variable I gave the path to the 'msvcp140_1.dll' file
119125-image.png

119131-image.png

I do not understand where the problem is coming from for already several days! Could somebody help me with this issue?

Thank you!




vs-generalvs-debuggingvs-setup
image.png (288.5 KiB)
image.png (20.0 KiB)
image.png (22.2 KiB)
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Rostyslav-5394 , welcome to Microsoft Q&A forum. Have you tried to restart VS Code, and reboot your machine?

0 Votes 0 ·

Hi! Thanks for the answer! Yes I did, many times, but it doesn't help :(

0 Votes 0 ·

@TianyuSun-MSFT Do you know anything else I could try to solve this issue? Or anybody else I could ask? Because I am struggling already for more than a week

0 Votes 0 ·

Hi @Rostyslav-5394 , have you tried the suggestions Viorel_1 and I mentioned? Feel free to contact us.

0 Votes 0 ·

Maybe also install vc_redist.x86.exe (if you did not do it already and even if the package is already shown in Control Panel), then check if msvcp140_1.dll is present in C:\Windows\SysWOW64.


0 Votes 0 ·
TianyuSun-MSFT avatar image
0 Votes"
TianyuSun-MSFT answered

Hi @Rostyslav-5394 ,

Perhaps you can try to copy the msvcp140_1.dll file to the python directory. For example(the path) C:\Users\XXXXXX\AppData\Local\Programs\Python\PythonXX

Or anybody else I could ask?

You can also ask this question on Stack Overflow tagged Visual Studio Code, or GitHub.

Best Regards,
Tianyu


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Rostyslav-5394 avatar image
0 Votes"
Rostyslav-5394 answered

@TianyuSun-MSFT @Viorel-1 thank you for the hints! Actually the reason was in the conflict of the tensorflow with python and some other packages. There are threads about it in the tensorflow issues on github.

If somebody comes across the similar issue: I solved the problem by completely removing the conda environment and reinstalling python 3.6.8 with tensorflow 1.14.0. Note that there can be some other packages that conflict with tensorflow, so I would recommend to install only python with tensorflow first, check for the conflicts (e.g. by doing import tensorflow) and if everything is smooth, install another package.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.