I can't believe after 8 years and 10,000 hours of using Python that I still get stumped by module import errors!!!! My tree is as follows:
pcode
/general
/latin
/latin
v_reading.py
/other
add_path.py
use_pydub.py
In the add_path.py
module I add some modules to the sys.path
like so:
import sys
vol='/users/me/'
gen_dir = f'{vol}Documents/pcode/'
sys.path.append(gen_dir)
gen_dir1 = f'{vol}Documents/pcode/byu_corpus/'
sys.path.append(gen_dir1)
gen_dir1 = f'{vol}Documents/pcode/latin/'
sys.path.append(gen_dir1)
gen_dir1 = f'{vol}Documents/pcode/latin/latin/'
sys.path.append(gen_dir1)
gen_dir1 = f'{vol}Documents/pcode/general/'
sys.path.append(gen_dir1)
gen_dir1 = f'{vol}Documents/pcode/other/'
sys.path.append(gen_dir1)
so when I run sys.path
I get inter alia:
/Users/me/Documents/pcode/other
/users/me/documents/pcode/
/users/me/documents/pcode/latin/ ## I'm not sure if this is necessary but I did it anyway
/users/me/documents/pcode/latin/latin/
/users/me/documents/pcode/general/
/users/me/documents/pcode/other/
The first lines of the use_pydub.py
module are as follows:
import sys
import add_path
from general import *
import latin
from latin.latin.v_reading import focus
I do not get an error when I run the module from pycharm but I do get the following error when I run it from command line:
ModuleNotFoundError: No module named 'latin.latin'
I don't understand why I can import the 'latin' folder but not the 'latin.latin' folder. I also tried renaming the second latin folder to latin2 but that did not help. I should also point out that there is no difference between the sys.path generated by pycharm and the sys.path generated by command line.