my file directory is simple:
/Users/dd/python/folder/
main.py
store.py
__init__.py
# store.py
class Store:
def __init__(self,location):
self.location = location
# main.py
from store import Store
store = Store('Kansas')
print(store.location)
when I run main.py I get this error:
ImportError: cannot import name 'Store' from 'store' (/Users/dd/opt/anaconda3/lib/python3.9/store.py)
When I check sys.path
I get a list that includes
- /Users/dd/opt/anaconda3/lib/python3.9
- /Users/dd/opt/anaconda3/lib/python3.9/site-packages
- ...
- /Users/dd/python/folder
From what I read in other questions if I add the path the way I did here at the end, it should work since the path list variable contains the local folder. Why does it ignore the local folder in this case?
Is it a problem with Anaconda?
I also couldn't find any examples of this error that included a path in parenthesis like this, where is that coming from?
I tried a virtual environment and that didn't change anything either. How can I set up python such that when I start a new folder the code operates from that folder?