0
If I set a variable as the directory from which I will import a file, such as:
a = 'C:\\Users\\Windows 7\\Desktop\\Program10.py
If I try from a import foo
, me is given Modulenotfounderror: No module named 'a'.
In context, the variable is set to directory in this loop:
d_user = getpass.getuser()
diret = "C:\\Users\\" + d_user
for root, dirs, files in os.walk(diret):
if lookfor in files:
a = join(root, lookfor)
break
And what I want to do is from a import func
or from a import variab
Does this solve: https://answall.com/questions/272043/%C3%89-poss%C3%Advel-name-one-m%C3%B3dulo-de-python-using-a-fun%C3%A7%C3%A3o-import/272045#272045
– Miguel
I believe it is because the variable is not considered in PYTHONPATH
– Onilol