Open AlexBlandin opened 5 years ago
This should have been fixed by https://github.com/replit/upm/pull/6 cc @turbio but I guess it wasn't.
Still an issue for me.
Looks like a user is having this same issue trying to use "pyjwt" instead of "jwt":
https://replit.com/talk/ask/Importing-issue-with-duplicate-import-names/132288
Looking into this, thanks for the report
So some packages, such as
py-ulid
, have a different name from the imported module, in this caseimport ulid
, or as usually done,from ulid import ULID
.If you import with Repl.it, then the first time you run it everything works fine. If you close and open again, the next time it tries to import the module
ulid
, which has a completely different interface and doesn't have aULID
class to import, and now no longer runs asulid
, which python attempts to resolve against rather thanpy-ulid
(and doesn't keep checking after the failure), doesn't have aULID
to import.Namely, UPM needs to either check against the existing packages that have been added, seeing if they are applicable, or it needs to check whether the packages it tried to include actually satisfy the interface of the program (even just flagging up that the
ulid
package doesn't haveULID
whilepy-ulid
, which is already in the Poetry file, does).This isn't really the fault of UPM, since Python is the one not checking for these when it is trying to resolve the imports, however this needs to be worked around in order to be Universal until (if ever) Python fixes this, especially for versions that do not have the fixed version should it ever happen.