Sanskar B.C.
Sanskar B.C.

Reputation: 41

Cannot import classes.(something) in Pycharm when that 'something' has already been defined

import classes.game import bcolors, Person

I have been trying to import game.py on my other file main.py but for some reason Pycharm shows this as unresolved error or something like that. What do I do?

Upvotes: 0

Views: 39

Answers (1)

Riptide
Riptide

Reputation: 516

If you type from classes.game import bcolors, Person, python will look for a file called classes.game.py, which doesn't exist.

Instead you should do

from game import bcolors, Person

as you're trying to import from the module 'game.py'.

Upvotes: 1

Related Questions