Hello,
I am on the personal paid plan. I was able to install enchant libraries for python:
However, when I try importing enchant in the server code like this:

I receive the following error:
ImportError: cannot import name ‘enchant’ from ‘enchant’ (/home/anvil/.env/lib/python3.10/site-packages/enchant/init.py)
And also this:
What can I do to fix this error? I want to use the levenshtein functions from the enchant library. I mentioned above I am on the personal plan so I thought custom libraries were possible for me to add.
Thanks for your help
Based on the enchant examples I can find, there’s no enchant
object inside of the enchant
module. You just import enchant
and use it from there.
1 Like
I uninstalled enchant and installed pyenchant. I kept the import as is though.
However, I now receive this error:
ImportError: The 'enchant' C library was not found and maybe needs to be installed. See https://pyenchant.github.io/pyenchant/install.html for details
at /home/anvil/.env/lib/python3.10/site-packages/enchant/_enchant.py:157
It looks like pyenchant requires a separate installation of enchant outside of the normal Python package manager. That’s not something you’ll solve through the Anvil IDE.
However, the Full Python 3 environment already has pyenchant installed with enchant configured. You can see the list of packages available on Full Python 3 at Anvil Docs | List of Packages
In the Full Python 3 environment, the following code just works:
import enchant
@anvil.server.callable
def check_spelling(name):
d = enchant.Dict("en_US")
return d.check(name)
If you need packages that aren’t on the Full Python 3 environment, I’d suggest contacting Anvil support to ask about how to get enchant installed in a customized build. That’s something they’d have to do on their end since pyenchant doesn’t come with the enchant binaries included.