Failed to run a Python file

Asked

Viewed 31 times

0

I want to make this executable code to use it in crontab:

import data
import mensagem
from skpy import Skype

sk = Skype(data.USERNAME, data.PASSWORD)

def post_message_group(mensage, channel_id): 
    "Post a message for group" 
    group_mensage = sk.chats.chat(channel_id)
    group_mensage.sendMsg(mensage)

post_message_group(mensagem.mensage, data.CHANNEL_ID)

When I execute him with a python /home/kali-john/Documentos/Projects/scripts/skype-mensage/main.py DA CERTO, it sends the message on skype

The problem when I spin it like this: /usr/bin/python3.9 /home/kali-john/Documentos/Projects/scripts/skype-mensage/main.py (Which is the way I should put in crontab), error appears:

  File "/home/kali-john/Documentos/Projects/scripts/skype-mensage/main.py", line 3, in <module>
    from skpy import Skype
ModuleNotFoundError: No module named 'skpy'

Same way, but one way turns the other of error: Mesmo caminho, porém um jeito roda do outro da erro

My whole system has python version 3.9.0

Can anyone tell me what it might be?

1 answer

0

You probably need to configure PYTHONPATH, in crontab you can run a script that runs your python program, but first you have to write the following export PYTHONPATH=/path/to/lib Where the path indicates where your bookshops are located

PS:don’t forget that at the beginning of each py script you need to write the following: ! #/usr/bin/env python3 This may be the problem if Libreria is an installed Libreria.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.