Reputation: 70
I am importing class from a file inside the folder source.
source --> file.py
from source.file import *
But the import does not work when I am outside conda environment. Why so?
Upvotes: 0
Views: 199
Reputation: 12192
Your Conda environment may use a different, newer, interpreter, which doesn't require __init__.py
files for a directory to be a package. To have it work outside the Conda environment, add an empty __init__.py
file inside the source
folder.
That would be the case if Conda uses Python 3.3+, while outside of Conda your Python executable defaults to a lower version, e.g., Python 2 (which is really out of date now, and should not be used anymore).
Upvotes: 2