You can take a look at my config which works fine in the circumstance: https://github.com/Graeme22/dotfiles/blob/1a51970dab0111f21568706258ddda166aa52121/.config/nvim/init.lua
Is your Python virtual environment activated? Can we see your entire init.lua? It's hard to know how to help here without more information.