Forums

pathlib import works in console but not in task

Hi,

Checking the logs for the task I set up for my script I see this error:

Traceback (most recent call last): File "/home/gziegler/changedetect/chngdetect.py", line 31, in <module> from pathlib import Path, PosixPath ImportError: No module named pathlib

2017-12-11 21:05:32 -- Completed task, took 13.00 seconds, return code was 1.

BUT if I run the script manually from the console, the script runs with no issues bringing the expected results....

Can anyone tell me what am I missing here?

Thanks!

Are you specifying which version of python you are using? Seems like you are using python2 or something.

You could use a hashbang inside of your file, or you could use a command like python3.6 /home/gziegler/changedetect/chngdetect.py instead of just /home/gziegler/changedetect/chngdetect.py in the task commandline.

Hi Conrad, actually I'm not specifying it.

This script should tun in 3.6 with no issues and it was my understanding that 3.6 was the default.

Nevertheless, if I use a hashbang, it still shows the same issue.

If I use python3.6 /home/gziegler/changedetect/chngdetect.py the log says:

ERROR:root:CONFIG File DOES NOT exist. Terminating!! CONFIG File DOES NOT exist. Terminating

I appreciate the guidance. I'm new to this...

Do you use a config file from within your code? That new error sounds like a forward step (ie. it does seem like it was running the wrong python version before).

This new error may be because you are in a different working directory. Try adding the correct path to syspath.

You were right, that was an error from my own script!

It was all related to paths, thanks for the insight.