pythoncompiler-errorspyinstallerexeapscheduler

"Failed to extract MSVCP140.dll: decompression resulted in return code 1!"


I'm receiving this error when I try to launch an executable I compiled from a .py file using pyinstaller. I've tried --onefile, not doing that, with and without upx, but this problem still persists, and it appears in a popup command-line window. The .py file works on its own like a charm so I don't think the problem's there.

Here is my code for the .py file:

import pywhatkit
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from apscheduler.triggers.cron import CronTrigger
import logging
import sqlalchemy

logging.basicConfig()
logging.getLogger('apscheduler').setLevel(logging.DEBUG)

def sendmsg():
    pywhatkit.sendwhatmsg(xx)

executors = {
    'default': ThreadPoolExecutor(20),
    'processpool': ProcessPoolExecutor(5)
}

job_defaults = {
    'coalesce': False, 
    'max_instances': 100
}

scheduler = BackgroundScheduler(executors=executors, job_defaults=job_defaults)
scheduler.configure({'apscheduler.daemon': False})
scheduler.add_jobstore('sqlalchemy', url='sqlite:///jobs.sqlite')

scheduler.start()

I've excluded unnecessary information from it.

Here is a picture of the error in the popup:

Error message

The dll file is also present in my system32 folder, I've also tried copying it and placing it in other locations as well but to no avail.

I'm open to any and all suggestions.


Solution

  • pyinstaller --onefile --upx-exclude=MSVCP140.dll filename --key 123456 -n test -F -w --upx-dir d:\directory_to_upx
    

    This worked to fix my problem.

    After this I encountered a problem where the program said that there was a problem with my sqlalchemy library.

    So I then changed my last line of imports to:

    from flask-sqlalchemy import SQLAlchemy
    

    And the last line of my code to:

    scheduler.add_jobstore(SQLAlchemyJobStore(url))
    

    Hope this helps anyone else who encounters the same problem!