-1

I am trying to run my program by clicking the .py file. I am able to do that in the simple program but not the one I am working on. In my program, I have many imports statements, is it because of that? when I click on the main.py file, the cmd black screen appears for a few seconds and closes itself.

My program uses the following libs

import time
import mysql.connector
from configparser import ConfigParser

from mysql.connector import Error
import os
import os.path as path
import datetime
import pandas as pd
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import TimeoutException
Mihail Duchev
  • 4,691
  • 10
  • 25
  • 32
skk
  • 25
  • 4
  • Why do you need to run the program by clicking on it? What OS are you on and what application is set to launch for clicking on .py files? – ggorlen Jul 25 '20 at 03:20
  • Does this answer your question? [Relative imports - ModuleNotFoundError: No module named x](https://stackoverflow.com/questions/43728431/relative-imports-modulenotfounderror-no-module-named-x). See also in Python documentation [Command line and environment](https://docs.python.org/3/using/cmdline.html). Please read the documentation of Python on using Python instead of asking Python programmers for help on issues caused by not reading the documentation. – Mofi Jul 25 '20 at 17:31

1 Answers1

0

Reasons why You shouldn't execute *.py directly

  1. The window will immedietly close when the program is done
  2. you will not know if any error is present in the code

You should probably use Command prompt or the terminal using this will give better clarity of errors

If you believe you are fine to execute *.py you can do it but I don't recommend it.

Good luck!

Sashank
  • 557
  • 6
  • 20
  • I can run the program using the pyCharm, but when i use the program to run using the cmd i get "C:\Users\kafle>C:\Users\kafle\PycharmProjects\OI_usingtd\test.py Traceback (most recent call last): File "C:\Users\kafle\PycharmProjects\OI_usingtd\test.py", line 6, in import requests ModuleNotFoundError: No module named 'requests'" I want to execute the program through the cmd so that i can use task Scheduler to run the program every 5 min. – skk Jul 25 '20 at 03:38