I am trying to run an implementation example and I cannot load the module from the current working directory, unless I explicitly add it to sys.path , then it works:
PyRun_SimpleString("import sys"); PyRun_SimpleString("sys.path.append(\".\")");
Shouldn't Python look for modules in the current directory?
Edit1 : tried only importing the module with
Py_Initialize(); PyRun_SimpleString("import multiply");
And still the following error fails:
Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named multiply
Edit2 . From sys.path docs :
If the script directory is not accessible (for example, if the interpreter is invoked interactively or if the script is read from standard input), path [0] is an empty string that directs Python to search for modules in the current directory first .
Not sure what this means is unavailable, but if I type sys.path[0] it is not empty:
/usr/lib/pymodules/python2.7
iabdalkader
source share