AttributeError: 'KerasClassifier' object has no attribute 'model'

展开阅读全文

AttributeError: 'Settings' object has no attribute 'DATABASE_ENGINE'

09-10

环境:Centos、python2.7.7 Django:1.7 south:0.7rnsettings.py 里的部分配置:rnINSTALLED_APPS = (rn 'south',rn 'django.contrib.admin',rn 'django.contrib.auth',rn 'django.contrib.contenttypes',rn 'django.contrib.sessions',rn 'django.contrib.messages',rn 'django.contrib.staticfiles',rn 'polls'rn)rn其中south:为同步模型到数据库的第三方模块,用来取代syncdb。rnpolls:为自己的投票应用。rn目前我执行python manage.py syncdb或者python manage.py startmigration polls --initial均报错,报错信息如下:rnTraceback (most recent call last):rn File "manage.py", line 10, in rn execute_from_command_line(sys.argv)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_linern utility.execute()rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 377, in executern self.fetch_command(subcommand).run_from_argv(self.argv)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 238, in fetch_commandrn klass = load_command_class(app_name, subcommand)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 41, in load_command_classrn module = import_module('%s.management.commands.%s' % (app_name, name))rn File "/usr/local/python2.7/lib/python2.7/importlib/__init__.py", line 37, in import_modulern __import__(name)rn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/management/commands/syncdb.py", line 5, in rn from south import migrationrn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/migration.py", line 17, in rn from south.db import dbrn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/db/__init__.py", line 9, in rn module_name = '.'.join(['south.db', settings.DATABASE_ENGINE])rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/conf/__init__.py", line 47, in __getattr__rn return getattr(self._wrapped, name)rn[color=#FF0000]AttributeError: 'Settings' object has no attribute 'DATABASE_ENGINE'[/color] 论坛

报错AttributeError: 'QWidget' object has no attribute 'setCentralWidget'如何解决

11-13

# -*- coding: utf-8 -*-rnrn# Form implementation generated from reading ui file 'sign.ui'rn#rn# Created: Sun Nov 13 17:09:05 2016rn# by: PyQt4 UI code generator 4.11.3rn#rn# WARNING! All changes made in this file will be lost!rnrnimport sysrnfrom PyQt4 import QtCore, QtGuirnrntry:rn _fromUtf8 = QtCore.QString.fromUtf8rnexcept AttributeError:rn def _fromUtf8(s):rn return srnrntry:rn _encoding = QtGui.QApplication.UnicodeUTF8rn def _translate(context, text, disambig):rn return QtGui.QApplication.translate(context, text, disambig, _encoding)rnexcept AttributeError:rn def _translate(context, text, disambig):rn return QtGui.QApplication.translate(context, text, disambig)rnrnclass Ui_MainWindow(object):rn def setupUi(self, MainWindow):rn MainWindow.setObjectName(_fromUtf8("MainWindow"))rn MainWindow.resize(747, 564)rn self.centralwidget = QtGui.QWidget(MainWindow)rn self.centralwidget.setObjectName(_fromUtf8("centralwidget"))rn self.label = QtGui.QLabel(self.centralwidget)rn self.label.setGeometry(QtCore.QRect(50, 30, 211, 61))rn self.label.setStyleSheet(_fromUtf8("\n"rn"font: 75 22pt \"Microsoft YaHei UI\";"))rn self.label.setObjectName(_fromUtf8("label"))rn self.label_2 = QtGui.QLabel(self.centralwidget)rn self.label_2.setGeometry(QtCore.QRect(50, 120, 81, 18))rn self.label_2.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_2.setObjectName(_fromUtf8("label_2"))rn self.lineEdit = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit.setGeometry(QtCore.QRect(50, 150, 331, 25))rn self.lineEdit.setObjectName(_fromUtf8("lineEdit"))rn self.label_3 = QtGui.QLabel(self.centralwidget)rn self.label_3.setGeometry(QtCore.QRect(50, 200, 81, 18))rn self.label_3.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_3.setObjectName(_fromUtf8("label_3"))rn self.lineEdit_2 = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit_2.setGeometry(QtCore.QRect(50, 230, 331, 25))rn self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))rn self.label_4 = QtGui.QLabel(self.centralwidget)rn self.label_4.setGeometry(QtCore.QRect(50, 280, 81, 18))rn self.label_4.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";"))rn self.label_4.setObjectName(_fromUtf8("label_4"))rn self.lineEdit_3 = QtGui.QLineEdit(self.centralwidget)rn self.lineEdit_3.setGeometry(QtCore.QRect(50, 310, 331, 25))rn self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))rn self.pushButton = QtGui.QPushButton(self.centralwidget)rn self.pushButton.setGeometry(QtCore.QRect(50, 380, 112, 34))rn self.pushButton.setStyleSheet(_fromUtf8("font: 9pt \"Microsoft YaHei UI\";\n"rn"background-color: rgb(215, 215, 215);"))rn self.pushButton.setObjectName(_fromUtf8("pushButton"))rn MainWindow.setCentralWidget(self.centralwidget)rn self.menubar = QtGui.QMenuBar(MainWindow)rn self.menubar.setGeometry(QtCore.QRect(0, 0, 747, 30))rn self.menubar.setObjectName(_fromUtf8("menubar"))rn MainWindow.setMenuBar(self.menubar)rn self.statusbar = QtGui.QStatusBar(MainWindow)rn self.statusbar.setObjectName(_fromUtf8("statusbar"))rn MainWindow.setStatusBar(self.statusbar)rnrn self.retranslateUi(MainWindow)rn QtCore.QMetaObject.connectSlotsByName(MainWindow)rnrn def retranslateUi(self, MainWindow):rn MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))rn self.label.setText(_translate("MainWindow", "欢迎注册", None))rn self.label_2.setText(_translate("MainWindow", "名字", None))rn self.label_3.setText(_translate("MainWindow", "密码", None))rn self.label_4.setText(_translate("MainWindow", "重复密码", None))rn self.pushButton.setText(_translate("MainWindow", "注册", None))rnrnif __name__ == "__main__":rn app = QtGui.QApplication(sys.argv)rn Form = QtGui.QWidget()rn ui = Ui_MainWindow()rn ui.setupUi(Form)rn Form.show()rn sys.exit(app.exec_())rnrnPython菜鸟,想简单实现一个用户注册注册界面,还没有与数据库进行连接,运行时报错rnTraceback (most recent call last):rn File "D:/PyCharm 2016.2.3/example/Sign.py", line 88, in rn ui.setupUi(Form)rn File "D:/PyCharm 2016.2.3/example/Sign.py", line 64, in setupUirn MainWindow.setCentralWidget(self.centralwidget)rnAttributeError: 'QWidget' object has no attribute 'setCentralWidget'rnrn求大神告知解决办法。rnrnrn 论坛

学习doc2vec的时候报错:AttributeError: 'str' object has no attribute 'words'

10-22

菜鸟一枚,研究了两天实在是不知道怎么解决,请教各位大神!rnrn我用的是Python2.7.10,gensim版本是0.12.2,目前在学习doc2vec模型。rn我在看官方教程(http://radimrehurek.com/gensim/models/doc2vec.html)的时候,一开始就过不了了,教程说:rnrnMake sure you have a C compiler before installing gensim, to use optimized (compiled) doc2vec training (70x speedup [blog]).rnrnInitialize a model with e.g.:rnrn>>> model = Doc2Vec(documents, size=100, window=8, min_count=5, workers=4)rnPersist a model to disk with:rnrn>>> model.save(fname)rn>>> model = Doc2Vec.load(fname) # you can continue training with the loaded model!rnThe model can also be instantiated from an existing file on disk in the word2vec C format:rnrn>>> model = Doc2Vec.load_word2vec_format('/tmp/vectors.txt', binary=False) # C text formatrn>>> model = Doc2Vec.load_word2vec_format('/tmp/vectors.bin', binary=True) # C binary formatrnrnrn我的代码如下,其中negForPy.txt大概长这样:rn[code=text]rn标准间太差 房间还不如3星的 而且设施非常陈旧.建议酒店把老的标准间从新改善.rn服务态度极其差,前台接待好象没有受过培训,连基本的礼貌都不懂,竟然同时接待几个客人;大堂副理更差,跟客人辩解个没完,要总经理的电话投诉竟然都不敢给。要是没有作什么亏心事情,跟本不用这么怕。rn地理位置还不错,到哪里都比较方便,但是服务不象是豪生集团管理的,比较差。下午睡了一觉并洗了一个澡,本来想让酒店再来打扫一下,所以,打开了,请打扫的服务灯,可是到晚上回酒店,发现打扫得服务灯被关掉了,而房间还是没有打扫过。rn1。我住的是靠马路的标准间。房间内设施简陋,并且的房间玻璃窗户外还有一层幕墙玻璃,而且不能打开,导致房间不能自然通风,采光不好。2。吃了三顿早餐,品种少得可怜。3。二楼餐厅被租出去了,价格特贵。原来订餐时告之房客可以打九折(房间服务指南里也明明白白写的,等到结帐时却告之海鲜和酒水是不能打折的,而且没有发票,找来经理才好不容易在第二天拿到发票。综合来说与四星级差距太大了!rn1。我住的是靠马路的标准间。房间内设施简陋,并且的房间玻璃窗户外还有一层幕墙玻璃,而且不能打开,导致房间不能自然通风,采光不好。2。吃了三顿早餐,品种少得可怜。3。二楼餐厅被租出去了,价格特贵。原来订餐时告之房客可以打九折(房间服务指南里也明明白白写的,等到结帐时却告之海鲜和酒水是不能打折的,而且没有发票,找来经理才好不容易在第二天拿到发票。综合来说与四星级差距太大了!rn[/code]rnrn[code=python]rn#encoding: utf-8rnfrom gensim.models.doc2vec import Doc2Vecrnrnwith open('negForPy.txt','r') as infile:rn documents = infile.readlines()rnmodel =Doc2Vec(documents,size=100,window=8,min_count=5,workers=4)rnrnmodel = Doc2Vec.load_word2vec_format('vectors1.txt', binary = False)[/code]rnrn第8行和之前的代码是不同的两种方法,我分开运行不管哪种方法都会报错,比如就像上面那样的代码直接运行,报错是:rnTraceback (most recent call last):rn File "E:\zzWorkFiles\ZZworkspace\Practise1\src\Prac1\draft2.py", line 6, in rn model =Doc2Vec(["aaaa","andajfiaihe","dfghiah","adoifjeng"],size=100,window=8,min_count=5,workers=4)rn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\doc2vec.py", line 584, in __init__rn self.build_vocab(documents, trim_rule=trim_rule)rn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\word2vec.py", line 495, in build_vocabrn self.scan_vocab(sentences, trim_rule=trim_rule) # initial surveyrn File "D:\programFiles\Python2.7.10\lib\site-packages\gensim-0.12.2-py2.7-win32.egg\gensim\models\doc2vec.py", line 627, in scan_vocabrn document_length = len(document.words)rnAttributeError: 'str' object has no attribute 'words'rnrnrn这种情况下应该怎么解决处理呢??rn跪求大神解答!rn 论坛

求助 关于Django ,AttributeError:'Topic' object has no attribute 'owner'

04-04

python编程入门到实践第十九章中的问题rnrnrn浏览器报错信息如下rnrn![图片说明](https://img-ask.csdn.net/upload/201904/04/1554356911_216497.png)rnrnrn**关于我的views.py 的代码如下**rnrn```rnfrom django.shortcuts import renderrnfrom django.http import HttpResponseRedirect, Http404rnfrom django.urls import reversernfrom django.contrib.auth.decorators import login_requiredrnrnfrom .models import Topic, Entryrnfrom .forms import TopicForm, EntryFormrnrnrnrn# Create your views here.rndef index(request):rn '''rn 学习笔记的主页rn :return:rn '''rn return render(request,'learning_logs/index.html')rndef topics(request):rn """Show all topics."""rn topics = Topic.objects.order_by('date_added')rn context = 'topics': topicsrn return render(request, 'learning_logs/topics.html', context)rnrnrnrnrn@login_requiredrndef new_topic(request):rn '''添加新主题'''rn if request.method != 'POST':rn form = TopicForm()rn else:rn form = TopicForm(request.POST)rn if form.is_valid():rn form.save()rn return HttpResponseRedirect(reverse('learning_logs:topics'))rn context = 'form':formrn return render(request,'learning_logs/new_topic.html',context)rnrnrndef edit_entry(request, entry_id):rn """Edit an existing entry."""rn entry = Entry.objects.get(id=entry_id)rn topic = entry.topicrn if topic.owner != request.user:rn raise Http404rnrn if request.method != 'POST':rn # Initial request; pre-fill form with the current entry.rn form = EntryForm(instance=entry)rn else:rn # POST data submitted; process data.rn form = EntryForm(instance=entry, data=request.POST)rn if form.is_valid():rn form.save()rn return HttpResponseRedirect(reverse('learning_logs:topic',rn args=[topic.id]))rnrn context = 'entry': entry, 'topic': topic, 'form': formrn return render(request, 'learning_logs/edit_entry.html', context)rnrnrndef topic(request, topic_id):rn """Show a single topic, and all its entries."""rn topic = Topic.objects.get(id = topic_id)rn # Make sure the topic belongs to the current user.rn if topic.owner != request.user:rn raise Http404rnrn entries = topic.entry_set.order_by('-date_added')rn context = 'topic': topic, 'entries': entriesrn return render(request, 'learning_logs/topic.html', context)rnrnrndef new_entry(request, topic_id):rn """Add a new entry for a particular topic."""rn topic = Topic.objects.get(id=topic_id)rn if topic.owner != request.user:rn raise Http404rnrn if request.method != 'POST':rn # No data submitted; create a blank form.rn form = EntryForm()rn else:rn # POST data submitted; process data.rn form = EntryForm(data=request.POST)rn if form.is_valid():rn new_entry = form.save(commit=False)rn new_entry.topic = topicrn new_entry.save()rn return HttpResponseRedirect(reverse('learning_logs:topic',rn args=[topic_id]))rnrn context = 'topic': topic, 'form': formrn return render(request, 'learning_logs/new_entry.html', context)rnrnrnrnrn``` 问答

没有更多推荐了,返回首页