我是Python的初学者。我正在使用Pycharm社区来编写Python脚本。我运行的代码有一些导入的自定义包,从那个IDE(Pycharm)代码按预期运行输出是好的。问题是如果我从本地驱动器运行该代码文件,双击提示说包找不到。为什么?请求帮助。
//我正在尝试运行的文件
from StackOverflow import Speak
import datetime
def time_compare():
now = 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 now < today12pm:
Speak.Sen_speak ("Good Morning Shiv!")
elif today12pm <= now and now < today4pm:
Speak.Sen_speak("Good Afternoon Shiv")
elif today4pm <= now and now <today6pm:
Speak.Sen_speak("Good Evening Shiv")
else:
Speak.Sen_speak("It seems to be night, are we really going to work")
input("Press Enter To exit")
time_compare()
我要导入的文件
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 To Speak")
result = Sen_speak(message)
if result == 'said':
print ("Said Successfully")
else:
print ("Error With Sound")
#Testing_method()
答案 0 :(得分:0)
也许你应该安装软件包,比如&#34; pip install StackOverflow&#34;或者您可以下载该软件包,然后运行脚本&#34; setup.py&#34;,使用&#34; python setup.py install&#34;,以便安装软件包
答案 1 :(得分:0)