(using answer instead of comment to use nicer formatting)
This can be due to wrong working directories. Consider the following example:
testfile = open("testfile.txt", 'w')
testfile.write("TEST")
testfile.close()
stored in the file /tmp/subdir/test.py
. If I now open a terminal and do the following:
cd /tmp/subdir
python /tmp/subdir/test.py
the testfile.txt
is created in /tmp/subdir
. But I can also do
cd /tmp
python /tmp/subdir/test.py
and testfile.txt
will be created in /tmp
, because it is the current working directory. You can even call python /tmp/subdir/test.py
from your home directory, and the testfile.txt
will be created there. It is now possible that "functionality A" works with any current working directory (cwd) and "functionality B" requires the cwd to be for example /root/Documents/path-to-code/
.
Perhaps https://askubuntu.com/questions/50085/setting-the-working-directory might help.