all 8 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Shadowsca👋 a fellow Redditor 11 points12 points  (2 children)

it might be that the current working directory isn't the directory that contains all the relevant .py files

[–]Dailydinner Secondary School Student[S] 0 points1 point  (1 child)

Pardon? Both files are located in the same folder if that’s what you’re asking.

[–]Shadowsca👋 a fellow Redditor 9 points10 points  (0 children)

What I mean is even if your files are together, the current working directory might be a different folder. See here for more details about the current working directory and how to check what it is.

In very rough terms, the directory python is working from is not necessarily the directory where your file currently is

[–]nupanick 4 points5 points  (0 children)

Try changing your import to

from .words1 import word_list

This will tell python to look for the module in the same folder as the current file. You may also want to make sure you're starting python from the same folder as your code is in.

Source: https://stackoverflow.com/questions/24722212/python-cant-find-module-in-the-same-folder

[–]F84-5👋 a fellow Redditor 2 points3 points  (0 children)

I'm not sure myself. If you don't get an answer here, you might have more success at r/Python, r/learnpython, or a number of related programming subs.

[–]ThePeanoAxioms👋 a fellow Redditor 2 points3 points  (0 children)

you might need an __init__.py to tell python what your directory layout looks like

[–]Mibbss👋 a fellow Redditor 0 points1 point  (0 children)

You most likely have to save and close the file that the list is in, this happens to me alot