I have a python file called hero.py that refers to other python files located in views.py (Both these files exist in the same folder).
hero.py code :
#!/usr/bin/env python3
from .views import main, returnSum, most_frequent, find_mine_site_view_id, get_user_Activity, initialise_analytics_reporting
list_of_mines = ['mine1', 'mine2', 'mine3']
start_date = 'yesterday'
end_date = 'yesterday'
main(list_of_mines, start_date, end_date)
After making the file executable with chmod +x hero.py and adding #!/usr/bin/env python3 at the top of hero.py, I get this error when running ./hero.py:
Traceback (most recent call last):
File "./hero.py", line 2, in <module>
from .views import main, returnSum, most_frequent, find_mine_site_view_id, get_user_Activity, initialise_analytics_reporting
ModuleNotFoundError: No module named '__main__.views'; '__main__' is not a package
I am aware that my views.py is not a package, I simply want to import the functions that exist within views.py
Not sure if it is an Ubuntu thing.
Please help
When running ls -la in the folder where both files exist:
total 72
drwxrwxr-x 8 llewellyn llewellyn 4096 May 13 06:39 .
drwxrwxr-x 6 llewellyn llewellyn 4096 May 11 19:19 ..
drwxrwxr-x 3 llewellyn llewellyn 4096 May 7 08:52 .idea
-rw-rw-r-- 1 llewellyn llewellyn 0 May 7 07:21 __init__.py
drwxrwxr-x 2 llewellyn llewellyn 4096 May 13 06:18 __pycache__
-rwxrwxr-x 1 llewellyn llewellyn 86 May 12 17:39 admin.py
-rwxrwxr-x 1 llewellyn llewellyn 108 May 12 17:40 apps.py
drwxrwxr-x 3 llewellyn llewellyn 4096 May 7 09:04 config
drwxrwxr-x 3 llewellyn llewellyn 4096 May 9 11:34 migrations
-rwxrwxr-x 1 llewellyn llewellyn 2607 May 12 17:40 models.py
-rwxrwxr-x 1 llewellyn llewellyn 16146 May 13 06:17 views.py
What am I doing wrong?