python - Package Not Found Error in Console when i Run my .py file from Explorer -


i'm beginner in python. i'am using pycharm community python script. code run have custom packages imported, ide(pycharm) code runs expected output good. problem if ran code file local drive double click prompt says package not found.why so?. requesting help.

// file i'm trying run

from stackoverflow import speak import datetime  def time_compare():     = datetime.datetime.now()     today12pm = now.replace(hour=12,minute=0,second=0,microsecond=1)     today4pm =  now.replace(hour=15,minute=0,second=0,microsecond=0)     today6pm = now.replace(hour=18, minute=0, second=0, microsecond=0)      if < today12pm:         speak.sen_speak ("good morning shiv!")     elif today12pm <= , < today4pm:         speak.sen_speak("good afternoon shiv")     elif today4pm <= , <today6pm:         speak.sen_speak("good evening shiv")     else:         speak.sen_speak("it seems night, going work")     input("press enter exit")  time_compare() 

the file i'am importing

import pyttsx   def sen_speak(msg):     try:         engine = pyttsx.init()         engine.setproperty('voice', 'hkey_local_machine\software\microsoft\speech\voices\tokens\tts_ms_en-us_zira_11.0')         engine.say(msg)         engine.runandwait()         return 'said'     except:         return 'err'   def testing_method():     message = raw_input("enter speak")     result = sen_speak(message)     if result == 'said':         print ("said successfully")     else:         print ("error sound")    #testing_method() 

similar questions have been asked here , here. if don't have stackoverflow package created in same folder script trying run, need use full path import using code such answers in links above:

import importlib.machinery  modulename = importlib.machinery.sourcefileloader('modulename','/path/to/stackoverflow.py').load_module() 

hope helps.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -