I get that error message when I run python testscript.py
I tried the recommendations given in link but was unsuccessful. My directory structure is as follows:
> bin
> - __init__.py
> - testscript.py
>
> test2
> - __init__.py
> - printstring_module.py
And my code in testscript.py
is as follows:
import sys
sys.path.append('C:\Users\KMF\Exercises\Projects\kevin_game\test2')
from test2 import printstring_module
printstring_module.printstrings("this is a test")
print("test over")
And the code for printstring_module.py
is as follows:
def printstrings(string="you didn't provide a string"):
print(string)
When I place both testscript.py
and printstring_module.py
in the same directory eg. bin folder the code works just fine.
Thanks and happy new year!