APScheduler:LookupError:No Trigger by the name "interval" is found

Source: Internet
Author: User
APScheduler:LookupError:No Trigger by the name "interval" is found Environment

python:2.6.6
pyinstaller:2.1
Apscheduler: The Beginning is 3.0.1, later is the 3.0.5 question one question describes

The Python program (python2.7) that was previously developed on another machine runs the Times incorrectly on the new machine

Lookuperror:no Trigger by the name "interval" is found

Program code

Import OS, time from
datetime import datetime from
apscheduler.schedulers.background Import Backgroundscheduler

def myjob ():
    print (' myjob:%s '% DateTime.Now ())
    Time.sleep (5)

if __name__ = = ' __ Main__ ':
    scheduler = Backgroundscheduler ()
    scheduler.add_job (myjob, ' interval ', Seconds=1)
    Scheduler.start ()

    try: While
        True:
            time.sleep (5)
    except (Keyboardinterrupt, Systemexit):
        Scheduler.shutdown ()
reason

is due to the lower version of Setuptools that leads to solutions

sudo pip install--upgrade setuptools
sudo pip install--ignore-installed Apscheduler

Then run the Python code above again to solve the problem. question two Problem Description

When the first problem is resolved, an error is generated when you run the executable file that you used to package the Pyinstaller

Traceback (most recent):
  File "<string>", line one, in <module>
  File ".../out00-pyz.pyz/ Apscheduler.schedulers.base ", line, Add_job
  File" .../out00-pyz.pyz/apscheduler.schedulers.base ", line 782 , in _create_trigger
  File ".../out00-pyz.pyz/apscheduler.schedulers.base", line 766, in _create_plugin_instance
Lookuperror:no Trigger by the name "interval" is found
reason

It feels as if Pyinstaller was using the wrong version of Apscheduler when it was packaged. (not sure) ... Solutions

Instead of using "' Interval ', Seconds=1" to do trigger in the Add_job method, create a Intervaltrigger object and then use the object when Add_job, that is:

Modify the original code

    Scheduler.add_job (myjob, ' interval ', Seconds=1)

For

    Trigger = Intervaltrigger (Seconds=1)
    scheduler.add_job (myjob, Trigger)

The complete code is as follows

Def myjob ():
    print (' myjob:%s '% DateTime.Now ())
    Time.sleep (5)

If __name__ = ' __main__ ':
    scheduler = Backgroundscheduler ()
    trigger = Intervaltrigger (Seconds=1)
    scheduler.add_job (myjob, Trigger)
    Scheduler.start ()

    try: While
        True:
            time.sleep (5)
    except (Keyboardinterrupt, Systemexit):
        Scheduler.shutdown ()

Then use Pyinstaller to repackage, and then run the executable file will not be an error.

Reprint please indicate this address in the form of link
This article address: http://blog.csdn.net/kongxx/article/details/50501605

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.