Python3: Could not find "vcomp140.dll (or one of its dependencies)" while trying to import nltk

0

When I try to import nltk on Python 3.9.1 on Windows 10 Pro, I get the following error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import nltk
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\nltk\__init__.py", line 142, in <module>
    from nltk.chunk import *
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\nltk\chunk\__init__.py", line 157, in <module>
    from nltk.chunk.api import ChunkParserI
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\nltk\chunk\api.py", line 13, in <module>
    from nltk.parse import ParserI
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\nltk\parse\__init__.py", line 100, in <module>
    from nltk.parse.transitionparser import TransitionParser
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\nltk\parse\transitionparser.py", line 19, in <module>
    from sklearn.datasets import load_svmlight_file
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\__init__.py", line 80, in <module>
    from . import _distributor_init  # noqa: F401
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\_distributor_init.py", line 23, in <module>
    WinDLL(op.abspath(vcomp140_dll_filename))
  File "C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\.libs\vcomp140.dll' (or one of its dependencies). Try using the full path with constructor syntax.

Any idea how to fix this? I've tried reinstalling ntlk (by typing pip install nltk), but it doesn't work. I've also tried pip install sklearn, no success. Even uninstalling nltk first and then reinstalling did not help, nor did restarting the computer after all this.

I can also tell that there is no subfolder (or file) called .libs (nor libs for that matter) in the C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn folder.

I've also tried to install Visual C++ from the link posted in an answer, but it does not work either as it says that it's already installed. Here's the log file, again my real username replaced with .

[25D4:3C14][2021-04-30T10:53:19]i001: Burn v3.7.3813.0, Windows v10.0 (Build 19041: Service Pack 0), path: C:\Users\<USERNAME>\Downloads\vc_redist.x64.exe, cmdline: ''
[25D4:3C14][2021-04-30T10:53:19]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\<USERNAME>\AppData\Local\Temp\dd_vcredist_amd64_20210430105319.log'
[25D4:3C14][2021-04-30T10:53:19]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\<USERNAME>\Downloads\vc_redist.x64.exe'
[25D4:3C14][2021-04-30T10:53:19]i000: Setting string variable 'WixBundleOriginalSourceFolder' to value 'C:\Users\<USERNAME>\Downloads\'
[25D4:3C14][2021-04-30T10:53:19]i000: Setting string variable 'WixBundleName' to value 'Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.23026'
[25D4:3C14][2021-04-30T10:53:19]i100: Detect begin, 10 packages
[25D4:3C14][2021-04-30T10:53:19]i000: File search: windows_uCRT_DetectKey, did not find path: C:\windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
[25D4:3C14][2021-04-30T10:53:19]i000: File search: windows_uCRT_DetectKeyExists, did not find path: C:\windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
[25D4:3C14][2021-04-30T10:53:19]i000: Setting numeric variable 'windows_uCRT_DetectKeyExists' to value 0
[25D4:3C14][2021-04-30T10:53:19]i102: Detected related bundle: {282975d8-55fe-4991-bbbb-06a72581ce58}, type: Upgrade, scope: PerMachine, version: 14.24.28127.4, operation: Downgrade
[25D4:3C14][2021-04-30T10:53:19]i108: Detected compatible package: vcRuntimeMinimum_x64, provider: Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v14, installed: {7DC387B8-E6A2-480C-8EF9-A6E51AE81C19}, version: 14.24.28127, chained: {0D3E9E15-DE7A-300B-96F1-B4AF12B96488}
[25D4:3C14][2021-04-30T10:53:19]i103: Detected related package: {7DC387B8-E6A2-480C-8EF9-A6E51AE81C19}, scope: PerMachine, version: 14.24.28127.0, language: 0 operation: Downgrade
[25D4:3C14][2021-04-30T10:53:19]i108: Detected compatible package: vcRuntimeAdditional_x64, provider: Microsoft.VS.VC_RuntimeAdditionalVSU_amd64,v14, installed: {8678BA04-D161-45BE-ACA4-CC5D13073F35}, version: 14.24.28127, chained: {BC958BD2-5DAC-3862-BB1A-C1BE0790438D}
[25D4:3C14][2021-04-30T10:53:19]i103: Detected related package: {8678BA04-D161-45BE-ACA4-CC5D13073F35}, scope: PerMachine, version: 14.24.28127.0, language: 0 operation: Downgrade
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: vcRuntimeMinimum_x64, state: Obsolete, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: vcRuntimeAdditional_x64, state: Obsolete, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows81_x86, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows81_x64, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows8_x86, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows8_x64, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows7_MSU_x86, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: Windows7_MSU_x64, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: WindowsVista_MSU_x86, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i101: Detected package: WindowsVista_MSU_x64, state: Absent, cached: None
[25D4:3C14][2021-04-30T10:53:19]i052: Condition 'VersionNT64 >= v6.0 OR (VersionNT64 = v5.2 AND ServicePackLevel >= 1)' evaluates to true.
[25D4:3C14][2021-04-30T10:53:19]i199: Detect complete, result: 0x0
[25D4:2BC0][2021-04-30T10:53:22]e000: Error 0x80070666: Cannot install a product when a newer version is installed.
python-3.x
windows
nltk
importerror
python-3.9
asked on Stack Overflow Apr 29, 2021 by hilssu • edited Apr 30, 2021 by hilssu

1 Answer

0

As @Rabindra suggests, the issue lies in missing Visual Studio C++ Redistributable binaries.

You can install them from the official link. They are dependency of many of the C++ libraries compiled on Windows that expose Python API (or python modules that are in fact interfacing into C++ libraries).

answered on Stack Overflow Apr 30, 2021 by sophros

User contributions licensed under CC BY-SA 3.0