首页 > 解决方案 > How do I fix WinError 126 for Pyenchant?

问题描述

I am relatively new to Python. I already know what most things are and do so now I am trying to work on as many projects as I can to get familiar with Python coding.

But here I've run into a speed bump. I'm trying to create something that takes in letters from a user to generate words ranging from 3 letters to the length of the word.

My code is okay, I think, but when I run it I get a WinError 126 and I'm not trying to import any dll files. I reckon it has something to do with Pyenchant. Please, may someone help me??

CODE & ERROR:

from itertools import permutations
import enchant

d = enchant.Dict("en_UK")
WORDS = set()
LETTERS = input("ENTER LETTERS: ")
PERMS = [i.upper() for i in LETTERS]

for n in range(2, len(LETTERS)):    
    for x in list(permutations(PERMS, n)):
        ANAGRAMS = "".join(x)
        if d.check(ANAGRAMS):
            WORDS.add(ANAGRAMS)
            
print(WORDS)

_________________________________________________________

Traceback (most recent call last):
  File "C:\Users\JAVA MANU\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\WordScapes cheat tool v2.py", line 2, in <module>
    import enchant
  File "C:\Users\JAVA MANU\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\enchant\__init__.py", line 81, in <module>
    from enchant import _enchant as _e
  File "C:\Users\JAVA MANU\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\enchant\_enchant.py", line 161, in <module>
    e = ctypes.cdll.LoadLibrary(enchant_lib_path)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 442, in LoadLibrary
    return self._dlltype(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

标签: python

解决方案


推荐阅读