When I just created a new project I had two py files - main.py and functions.py - in the project folder "my project". In main.py I imported functions.py and it worked fine. But then I created some folders in "my project" folder and put main.py and functions.py in one of them. They are still in the same folder, but in main.py it says that functions.py is an unresolved reference.
P.S. Using PyCharm on macos
Simple answer: you should make a package in your directory tree and PyCharm will pick it up easily.
project_root
├── my_project
│ ├── __init__.py
│ ├── main.py
│ ├── functions.py
Open project_root in PyCharm and these imports should work correctly:
from my_project import functions
or
import my_project.functions
# you can also do 'import my_project.functions as functions'
my_project.functions.do_something('argument')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With