python 3.x - python3 relative import not working: ImportError: cannot import name 'gmail' -


i understand relative import has explicit in python 3, can't figure 1 out.

i have 1 directory called work , files main.py , gmail.py

in main.py, used have "import gmail" in python 2

i used 2to3, , line changed "from . import gmail"

user@ubuntu:~/work$ python main.py  traceback (most recent call last):   file "main.py", line 7, in <module>     . import gmail importerror: cannot import name 'gmail' 

what doing wrong?

by way, when "python gmail.py", works fine.

$ cat main.py  . import gmail  $ cat gmail.py  print('test') 

====================================== ok found works $ cat main.py import gmail

so why did 2to3 change not work? , why people use "from . import gmail" when "import gmail" works?

the complete answer i've been able find here: relative imports in python 3

better have written up.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -