0

I have made a .py file (i call it acomp.py) that reads from and SQL database and after a series of calculations and exports its output to an excel file.Later I sends this .xlsx file by e-mail to various persons.

I wish to put it inside another python script so I can use the schedule module to call acomp.py aromatically at selected times, run it and send the output by email:

def exec_scrpit():
    exec(open("acomp.py", encoding='utf-8').read())
    send_email()

schedule.every().day.at("07:20").do(exec_scrpit)

When the second script calls the fist it messes with the acom.py internal functions returning the error:

"  File "<string>", line 125, in <lambda>
NameError: name 'modalidade_contrato' is not defined"

This 'modalidade_contrato' is defined inside acomp.py and it runs perfectly when I execute acom.py directly.

Any ideia how should I proceed? I think my whole strategy is not usual, but I have to do it this way because I do not have admin privileges on my computer.

2
  • What is Modalidade_contrato? A class? A function? A module? Commented Apr 24, 2020 at 18:18
  • it is a function. I call it inside a lambda function of the acomp.py file. Commented Apr 24, 2020 at 18:21

1 Answer 1

1

I learned that you can simply run it as you would in cmd:

os.system(r'"C:\Users\user.name\Miniconda3\python.exe acomp.py"')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.