0

I am using Python Anywhere to run a scheduled task. I have written the script and tested it running from the file and it works fine. However, if I used a scheduled task I get an error message.

Traceback (most recent call last):
  File "/home/myaccount/myfile.py", line 45, in <module>
    activeData = shelve.open('activeData')
  File "/usr/lib/python2.7/shelve.py", line 243, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
  File "/usr/lib/python2.7/shelve.py", line 227, in __init__
    Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
  File "/usr/lib/python2.7/anydbm.py", line 84, in open
    mod = __import__(result)
ImportError: No module named gdbm

I'm confused as to why the script runs fine if I run it from the script, but fails when triggered from the scheduled tasks, and why this would produce a missing module.

Any help appreciated.

gdhp
  • 31
  • 1
  • just check whether your deployed environment having all the required packages. – Subbu VidyaSekar Apr 05 '20 at 02:19
  • Are you using a virtual environment? Open a Bash console on the website and install the package there. https://askubuntu.com/questions/720416/no-module-named-gdbm – Joe Apr 05 '20 at 05:09
  • https://stackoverflow.com/questions/49113718/gdbm-doesnt-work-with-python-3-6-and-anaconda – Joe Apr 05 '20 at 05:10
  • Ah, that might not work: https://www.pythonanywhere.com/forums/topic/13145/ – Joe Apr 05 '20 at 05:12
  • You don't have sudo, but read this https://www.pythonanywhere.com/forums/topic/14732/ – Joe Apr 05 '20 at 05:15
  • What command do you use to run your task? What was the command used in the console? Or was it run using Run button in PythonAnywhere editor? What is the python version you want to run your task with? Is there a shebang on top of the file? – Filip Apr 05 '20 at 17:47

0 Answers0