Import class from a module

Question:

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

hi. I am a beginner and want to migrate my exercises code files from Pydroid to Replit. In Pydroid I have a folder with __init__ file (empty) and I am able to use an import statement to import classes from one file to another in the same folder like ‘from Foo import foo’. In Replit it doesn’t seem to work. What I am missing ? TYSM.

Hey @7625965 welcome to the forums!

It should work if those files or modules exist. Could you provide a link to your Repl so we can look into what could be causing the issue?

Could you show your files tab?

If data_collector.py is in a folder, you need to specify that.

from folder_name.data_collector import make_data_dictionary
2 Likes

hope this helps TYSM

That is not your files tab, that’s your list of repls. If you want to import something, it needs to be in the same Repl.

4 Likes

Just adding on here: repl data don’t carry over to other repls, so you can’t import files from other repls just like that. You’ll need to manually upload those files into the repl you want, to access that file.
Hope this helps!

4 Likes

Question:

Repl link/Link to where the bug appears:

Screenshots, links, or other helpful context:

code snippet

can’t figure out why I am getting ModuleNotFoundError

here is a link to a repl:
https://replit.com/@7625965/applicantage?s=app

here is a screenshot of files in a “snap” folder

here is an error I get:

what I am doing wrong?

TYA

Those are not files, but individual Repls.

Replit folders are separate from folders INSIDE of Repls.

Click this button, and there should be a button near the top-right to create a folder INSIDE of your Repl:

4 Likes

Thank you @QwertyQwerty88. Now how I add the repls to the folder?

Hey @7625965!

You can’t add Repls to a Folder in a Repl, you can copy the code and move it to your single Repl.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.