replit / upm

⠕ Universal Package Manager - Python, Node.js, Ruby, Emacs Lisp.
https://repl.it
Other
1.06k stars 91 forks source link

Imports incorrect modules in Python when Poetry already has correct module #15

Open AlexBlandin opened 5 years ago

AlexBlandin commented 5 years ago

So some packages, such as py-ulid, have a different name from the imported module, in this case import 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 a ULID class to import, and now no longer runs as ulid, which python attempts to resolve against rather than py-ulid (and doesn't keep checking after the failure), doesn't have a ULID 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 have ULID while py-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.

raxod502 commented 5 years ago

This should have been fixed by https://github.com/replit/upm/pull/6 cc @turbio but I guess it wasn't.

kaijchang commented 4 years ago

Still an issue for me.

jahands commented 3 years ago

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

blast-hardcheese commented 10 months ago

Looking into this, thanks for the report