Forums

Module Requests showing error when used with Tasks feature

Hello, I am currently having a strange behavior of Pythonanywhere Tasks. When I use the module Requests to trigger MailGun API to send an email it works just fine (using virtual environment). But if I program my script to run through a Task I get the following error: "ModuleNotFoundError: No module named 'requests'". Noe that I am using also a virtual environment to run the .py in the Tasks. Any idea whats going on here? Thanks a lot!

What have you done to use the virtualenv in your tasks?

I used as its written here: https://help.pythonanywhere.com/pages/VirtualEnvInScheduledTasks/ And it works. Only fails in the last lines of my program (with the Requests as explained above).

Any idea why this is happening? My task has the command: /home/username/.virtualenvs/last-parser/bin/python /home/username//.virtualenvs/last-parser/bin/parsing_cnsb.py

are you still seeing problems? according to our logs your last task run seemed to complete successfully?

Yes, working ok now. It's very strange: if I run the script with virenv it's ok and doesnt say that it's missing Requests module, and if I use the same method with Task it's says it's missing module. In the end I installed with pip Requests module in the virenv and now appears to be fine. thanks.

maybe there were two different virtualenvs? in any case, glad it's working now :)