今天,在Quora上冲浪时,我遇到了python可以做的惊人事情的答案.我试图使用pyttsx 文本到语音转换器,这给了我一个No module named Win32com.client错误.
关于这个错误有很多答案,但是大多数答案还不够(至少对我而言),因为提出的解决方案不符合要求.
对于初学者,我使用的是Python2.7,并且C:/Windows/System32在我的C:/Python27/Scripts文件夹中与关键字"pywin32"相关的任何脚本中都没有DLL .我需要一个具体的解决方案
这是我到目前为止所尝试的:
>>> import pyttsx
>>> engine = pyttsx.init()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pyttsx\__init__.py", line 39, in init
eng = Engine(driverName, debug)
File "C:\Python27\lib\site-packages\pyttsx\engine.py", line 45, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Python27\lib\site-packages\pyttsx\driver.py", line 64, in __init__
self._module = __import__(name, globals(), locals(), [driverName])
File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 19, in <module>
import win32com.client …Run Code Online (Sandbox Code Playgroud) 我正在尝试将初始化程序表单转换tf.Variable为tf.get_variablefor,Cudnn_GRU但我一直收到此错误.我必须转换因为tensorflow不允许在循环/控制流函数中初始化并且只允许lambda初始化器或通过tf.get_variable
我已将问题简化为以下最小示例:
import tensorflow as tf
e = tf.random_uniform_initializer(-0.1, 0.1)
i = tf.constant(0)
def func():
gru_fw = tf.contrib.cudnn_rnn.CudnnGRU(num_layers=1, num_units=75, input_size=25)
# original line: commented out and working if not under a control flow mechanism
# param_fw = tf.Variable(tf.random_uniform([gru_fw.params_size()], -0.1, 0.1), validate_shape=False)
# converted line
param_fw = tf.get_variable("abcd", shape=[gru_fw.params_size()],initializer=e, validate_shape=False)
return param_fw
def func2():
### repeat the same thing from func1
pass
result = tf.cond(tf.equal(i, tf.constant(0)),func,func2)
Run Code Online (Sandbox Code Playgroud)
回溯如下:
Traceback (most recent call last):
File "test_run_error.py", …Run Code Online (Sandbox Code Playgroud) 所以我正在学习Django教程,在页面的中间部分,我必须在mysite\polls\views.py中进行一些更改.
这就是我如何进行更改class IndexView并class DetailView按照要求:
mysite的\调查\ views.py:
class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'
def get_queryset(self):
"""
Return the last five published questions (not including those set to be
published in the future).
"""
return Question.objects.filter(
pub_date__lte=timezone.now()
).order_by('-pub_date')[:5]
class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'
def get_queryset(self): #The Error Points Here
"""
Excludes any questions that aren't published yet.
"""
return Question.objects.filter(pub_date__lte=timezone.now())
Run Code Online (Sandbox Code Playgroud)
mysite的\调查\ urls.py:
from django.conf.urls import url
from . import …Run Code Online (Sandbox Code Playgroud)