Importing issue with duplicate import names
Sorry for not providing a repl, but it shouldn't be necessary.
Here's my issue: I'm trying to use pyjwt for encoding tokens for my webapp. This library is imported via import jwt. Unfortunately, this import statement causes Replit to install the jwt library instead of pyjwt. As a result, I keep getting an error that the encode module doesn't exist (because it's trying to import it from jwt instead of pyjwt).
I've tried removing jwt from my poetry files, I had some brief success using pip to uninstall both libraries and then reinstalling pyjwt, but nothing seems to stick and now I can't even get that workaround to succeed. Bottom line: I need replit to stop installing the wrong jwt library.
Any suggestions?
try doing this:
import os os.system('pip install pyjwt')
That should install it via pip
, and if it is already installed, it should just give you a warning that the dependency is already met but continue running.
I'm not really having any issues installing the correct package... the issue that I'm having is that repl.it automatically installs the wrong package, as well, and that package takes precedence when importing.
I found a temporary solution in using an alternate library, but, as with most of my questions, I'd prefer to find a more straight-forward solution to the issue than working around it. In any case, thanks!
@InvisibleOne
Sorry for the late reply. I just came across your question while searching for the same issue. Luckily, I have found one solution from replit's documentation. Just add comment next your "duplicate" import library with the right one. It's something like this:
ps. I'm not really sure
upm package
part but you only need to specify the correct library in the brackets. And I didn't save the link to the documentation, sorry.