N = int(sys.argv[1])报错

我是在Eclipse下编写的python程序,每次用N = int(sys.argv[1])都会报错,求各位大神帮忙指导一下,万分感谢图片说明

1个回答

程序怎么运行的,有没有给参数。这个参数是启动传入的,不是运行程序后输入。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
sys.argv[1]报错;命令行参数

![图片说明](https://img-ask.csdn.net/upload/201910/01/1569943881_464034.png) sys.argv[1]报错,显示超出列表范围 然后查了下资料,了解了argv的一些基本用法,在这里需要传入其他的参数 这个具体应该传什么参数,是怎么确定的,麻烦路过的大神指点一下

报错:sys.argv[1] IndexError: list index out of range?

运行时报错:firstFolder = sys.argv[1] IndexError: list index out of range 怎么回事? ``` import numpy as np import cv2 import sys from matplotlib import pyplot as plt # img = cv2.imread('logo.png',0) # # Initiate ORB detector # orb = cv2.ORB_create() # # find the keypoints with ORB # kp = orb.detect(img,None) # # compute the descriptors with ORB # kp, des = orb.compute(img, kp) # # draw only keypoints location,not size and orientation # img2 = cv2.drawKeypoints(img, kp, None, color=(0,255,0), flags=0) # plt.imshow(img2), plt.show() from os import listdir from os.path import isfile, join class Application: def __init__(self, extractor, detector): self.extractor = extractor self.detector = detector def train_vocabulary(self, file_list, vocabulary_size): kmeans_trainer = cv2.BOWKMeansTrainer(vocabulary_size) for path_to_image in file_list: img = cv2.imread(path_to_image, 0) kp, des = self.detector.detectAndCompute(img, None) kmeans_trainer.add(des) return kmeans_trainer.cluster() def extract_features_from_image(self, file_name): image = cv2.imread(file_name) return self.extractor.compute(image, self.detector.detect(image)) def extract_train_data(self, file_list, category): train_data, train_responses = [], [] for path_to_file in file_list: train_data.extend(self.extract_features_from_image(path_to_file)) train_responses.append(category) return train_data, train_responses def train_classifier(self, data, responses): n_trees = 200 max_depth = 10 model = cv2.ml.RTrees_create() eps = 1 criteria = (cv2.TERM_CRITERIA_MAX_ITER, n_trees, eps) model.setTermCriteria(criteria) model.setMaxDepth(max_depth) model.train(np.array(data), cv2.ml.ROW_SAMPLE, np.array(responses)) return model def predict(self, file_name): features = self.extract_features_from_image(file_name) return self.classifier.predict(features)[0] def train(self, files_array, vocabulary_size=12): all_categories = [] for category in files_array: all_categories += category vocabulary = self.train_vocabulary(all_categories, vocabulary_size) self.extractor.setVocabulary(vocabulary) data = [] responses = [] for id in range(len(files_array)): data_temp, responses_temp = self.extract_train_data(files_array[id], id) data += data_temp responses += responses_temp self.classifier = self.train_classifier(data, responses) def error(self, file_list, category): responses = np.array([self.predict(file) for file in file_list]) _responses = np.array([category for _ in range(len(responses))]) return 1 - np.sum(responses == _responses) / len(responses) def get_images_from_folder(folder): return ["%s/%s" % (folder, f) for f in listdir(folder) if isfile(join(folder, f))] def start(folders, detector_type, voc_size, train_proportion): if detector_type == "SIFT": # "Scale Invariant Feature Transform" extract = cv2.xfeatures2d.SIFT_create() detector = cv2.xfeatures2d.SIFT_create() else: # "Speeded up Robust Features" extract = cv2.xfeatures2d.SURF_create() detector = cv2.xfeatures2d.SURF_create() flann_params = dict(algorithm=1, trees=5) matcher = cv2.FlannBasedMatcher(flann_params, {}) extractor = cv2.BOWImgDescriptorExtractor(extract, matcher) train = [] test = [] for folder in folders: images = get_images_from_folder(folder) np.random.shuffle(images) slice = int(len(images) * train_proportion) train_images = images[0:slice] test_images = images[slice:] train.append(train_images) test.append(test_images) app = Application(extractor, detector) app.train(train, voc_size) total_error = 0.0 for id in range(len(test)): print(app.error(train[id], id)) test_error = app.error(test[id], id) print(test_error) print("---------") total_error = total_error + test_error total_error = total_error / float(len(test)) print("Total error = %f" % total_error) firstFolder = sys.argv[1] secondFolder = sys.argv[2] detectorType = sys.argv[3] vocSize = int(sys.argv[4]) trainProportion = float(sys.argv[5]) start([firstFolder, secondFolder], detectorType, vocSize, trainProportion) ```

关于python中sys的函数调用问题

这几天在学《笨方法学python》,里面的习题14代码如下: from sys import agrv script, user_name = argv prompt = '>' print "Hi %s, i'm the %s script."%(user_name, script) print "i'd like to ask you a few quertions." print "do you like me %s?"%user_name likes = raw_input(prompot) print "where di you live %s?"%user_name lives = raw_input(prompt) print "what kind of computer do you have?" computer = raw_input(prompt) print """ alright, so you said %r about liking me. you live in %r. not sure where that is. and you have a %r computer. nice. """%(likes, lives, computer) 为什么我运行的时候会报错 cannot import name agrv 意思是从sys里面无法调用argv吗?为什么会出现这种情况? 谢谢!

请教一些关于pyqt5的小白问题

如下代码所示,我想在一个Dialog的Qwidget里绘制一个矩形,但在发送信号调用DrawRec的时候并没有绘制出图形,但是把DrawRec放在paintEvent里就能绘制出来,难道Qwidget只能在paintEvent里绘制图形?还是因为我没能正确调用呢? ``` import sys from PyQt5.QtCore import pyqtSlot, pyqtSignal from PyQt5.QtWidgets import QApplication, QDialog,QWidget, QVBoxLayout from PyQt5.QtGui import QPainter, QColor, QBrush, QPen, QPalette class myWidget(QWidget): def __init__(self): super().__init__() self.setBackgroundRole(QPalette.Midlight) self.setAutoFillBackground(True) def paintEvent(self, e): # self.DrawRec(10, 10, 50, 50) pass @pyqtSlot(int, int, int, int) # 定义槽函数 def DrawRec(self, x1, y1, x2, y2): qp = QPainter() qp.begin(self) col = QColor(0, 0, 0) col.setNamedColor('#d4d4d4') qp.setPen(col) qp.setBrush(QColor(200, 0, 0)) qp.drawRect(x1, y1, x2, y2) qp.end() class Dialog(QDialog): _signal = pyqtSignal(int, int, int, int) # 定义信号 def __init__(self, parent=None): super(Dialog, self).__init__(parent) self.setObjectName("Dialog") self.resize(400, 300) self.setSizeGripEnabled(True) wigglyWidget = myWidget() layout = QVBoxLayout() layout.addWidget(wigglyWidget) self.setLayout(layout) self._signal.connect(wigglyWidget.DrawRec) # connect self._signal.emit(20, 20, 50, 50) # 信号发送 if __name__ == "__main__": app = QApplication(sys.argv) dlg = Dialog() dlg.show() sys.exit(app.exec_()) ```

请各位大佬帮看看问题出在哪里~~使用PyQt的设计师 信号与槽不响应

点击 “求解”按钮之后,为什么不输出结果? connect()函数不是已经连接了要响应的函数了吗? ![图片说明](https://img-ask.csdn.net/upload/201709/16/1505575508_586419.png) #!/usr/bin/python3 # -*- coding: UTF-8 -*- from PyQt5.QtWidgets import QWidget,QApplication from PyQt5 import uic from qua_rc import Ui_MainWindow import sys import numpy #qtCreatorFile = "qua.ui" #Ui_MainWindow,QtBaseClass = uic.loadUiType(qtCreatorFile) class MyWindow(QWidget,Ui_MainWindow): def __init__(self): super(MyWindow,self).__init__() self.setupUi(self) self.calc_qua_button.clicked.connect(self.quadretic) def quadretic(self): a = self.a_box.toPlainText().toDouble() b = self.b_box.toPlainText().toDouble() c = self.c_box.toPlainText().toDouble() p = numpy.poly1d([a, b, c]) L = p.r self.result1_window.setText(str(L[0])) self.result1_window.setText(str(L[1])) if __name__ == '__main__': app = QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec_())

【求助】Python新手上路,报错令人头大!

# OpenCV的库,如下是代码 ``` import os import sys import cv2 import numpy as np def normalize(X, low, high, dtype=None): """Normalizes a given array in X to a value between low and high.""" X = np.asarray(X) minX, maxX = np.min(X), np.max(X) # normalize to [0...1]. X = X - float(minX) X = X / float((maxX - minX)) # scale to [low...high]. X = X * (high-low) X = X + low if dtype is None: return np.asarray(X) return np.asarray(X, dtype=dtype) def read_images(path, sz=None): """Reads the images in a given folder, resizes images on the fly if size is given. Args: path: Path to a folder with subfolders representing the subjects (persons). sz: A tuple with the size Resizes Returns: A list [X,y] X: The images, which is a Python list of numpy arrays. y: The corresponding labels (the unique number of the subject, person) in a Python list. """ c = 0 X,y = [], [] for dirname, dirnames, filenames in os.walk(path): for subdirname in dirnames: subject_path = os.path.join(dirname, subdirname) for filename in os.listdir(subject_path): try: if (filename == ".directory"): continue filepath = os.path.join(subject_path, filename) im = cv2.imread(os.path.join(subject_path, filename), cv2.IMREAD_GRAYSCALE) if (im is None): print ("image " + filepath + " is none") else: print (filepath) # resize to given size (if given) if (sz is not None): im = cv2.resize(im, (200, 200)) X.append(np.asarray(im, dtype=np.uint8)) y.append(c) except IOError as (errno, strerror): print ("I/O error({0}): {1}".format(errno, strerror)) except: print ("Unexpected error:", sys.exc_info()[0]) raise print (c) c = c+1 print (y) return [X,y] def face_rec(): names = ['Gaving', 'Mengxing', 'Cookie'] if len(sys.argv) < 2: print ("USAGE: facerec_demo.py </path/to/images> [</path/to/store/images/at>]") sys.exit() [X,y] = read_images(sys.argv[1]) y = np.asarray(y, dtype=np.int32) if len(sys.argv) == 3: out_dir = sys.argv[2] model = cv2.face.createEigenFaceRecognizer() model.train(np.asarray(X), np.asarray(y)) camera = cv2.VideoCapture(0) face_cascade = cv2.CascadeClassifier('E:\\OPCV\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_default.xml') while (True): read, img = camera.read() faces = face_cascade.detectMultiScale(img, 1.3, 5) for (x, y, w, h) in faces: img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) roi = gray[x:x+w, y:y+h] try: roi = cv2.resize(roi, (200, 200), interpolation=cv2.INTER_LINEAR) print (roi.shape) params = model.predict(roi) print ("Label: %s, Confidence: %.2f" % (params[0], params[1])) cv2.putText(img, names[params[0]], (x, y - 20), cv2.FONT_HERSHEY_SIMPLEX, 1, 255, 2) if (params[0] == 0): cv2.imwrite('face_rec.jpg', img) except: continue cv2.imshow("camera", img) if cv2.waitKey(1000 / 12) & 0xff == ord("q"): break cv2.destroyAllWindows() if __name__ == "__main__": face_rec() def original(): # This is where we write the images, if an output_dir is given # in command line: out_dir = None names = ['Gaving', 'Mengxing', 'Cookie'] # You'll need at least a path to your image data, please see # the tutorial coming with this source code on how to prepare # your image data: if len(sys.argv) < 2: print ("USAGE: facerec_demo.py </path/to/images> [</path/to/store/images/at>]") sys.exit() # Now read in the image data. This must be a valid path! [X,y] = read_images(sys.argv[1]) # Convert labels to 32bit integers. This is a workaround for 64bit machines, # because the labels will truncated else. This will be fixed in code as # soon as possible, so Python users don't need to know about this. # Thanks to Leo Dirac for reporting: y = np.asarray(y, dtype=np.int32) # If a out_dir is given, set it: if len(sys.argv) == 3: out_dir = sys.argv[2] # Create the Eigenfaces model. We are going to use the default # parameters for this simple example, please read the documentation # for thresholding: #model = cv2.face.createLBPHFaceRecognizer() model = cv2.face.createEigenFaceRecognizer() # Read # Learn the model. Remember our function returns Python lists, # so we use np.asarray to turn them into NumPy lists to make # the OpenCV wrapper happy: model.train(np.asarray(X), np.asarray(y)) # We now get a prediction from the model! In reality you # should always use unseen images for testing your model. # But so many people were confused, when I sliced an image # off in the C++ version, so I am just using an image we # have trained with. # # model.predict is going to return the predicted label and # the associated confidence: camera = cv2.VideoCapture(0) face_cascade = cv2.CascadeClassifier('./cascades/haarcascade_frontalface_default.xml') while (True): read, img = camera.read() faces = face_cascade.detectMultiScale(img, 1.3, 5) for (x, y, w, h) in faces: img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) roi = gray[x:x+w, y:y+h] roi = cv2.resize(roi, (200, 200), interpolation=cv2.INTER_LINEAR) print (roi.shape) params = model.predict(roi) print ("Label: %s, Confidence: %.2f" % (params[0], params[1])) cv2.putText(img, names[params[0]], (x,y - 20), cv2.FONT_HERSHEY_SIMPLEX, 1, 255, 3) cv2.imshow("camera", img) if cv2.waitKey(1000 / 12) & 0xff == ord("q"): break [p_label, p_confidence] = model.predict(np.asarray(X[0])) # Print it: print ("Predicted label = %d (confidence=%.2f)" % (p_label, p_confidence)) # Cool! Finally we'll plot the Eigenfaces, because that's # what most people read in the papers are keen to see. # # Just like in C++ you have access to all model internal # data, because the cv::FaceRecognizer is a cv::Algorithm. # # You can see the available parameters with getParams(): print (model.getParams()) # Now let's get some data: mean = model.getMat("mean") eigenvectors = model.getMat("eigenvectors") # We'll save the mean, by first normalizing it: mean_norm = normalize(mean, 0, 255, dtype=np.uint8) mean_resized = mean_norm.reshape(X[0].shape) if out_dir is None: cv2.imshow("mean", mean_resized) else: cv2.imwrite("%s/mean.png" % (out_dir), mean_resized) # Turn the first (at most) 16 eigenvectors into grayscale # images. You could also use cv::normalize here, but sticking # to NumPy is much easier for now. # Note: eigenvectors are stored by column: for i in xrange(min(len(X), 16)): eigenvector_i = eigenvectors[:,i].reshape(X[0].shape) eigenvector_i_norm = normalize(eigenvector_i, 0, 255, dtype=np.uint8) # Show or save the images: if out_dir is None: cv2.imshow("%s/eigenface_%d" % (out_dir,i), eigenvector_i_norm) else: cv2.imwrite("%s/eigenface_%d.png" % (out_dir,i), eigenvector_i_norm) # Show the images: if out_dir is None: cv2.waitKey(0) cv2.destroyAllWindows() ``` [图片说明](https://img-ask.csdn.net/upload/201904/23/1555987806_94322.jpg) 一直报错,第一次发帖求助,希望大佬不吝赐教!

RK3288 make otapackage 报错ValueError: need more than 1 value to unpack

mkbootimg_args = (str) multistage_support = (str) 1 recovery_api_version = (int) 2 selinux_fc = (str) /tmp/targetfiles-WQjmn2/BOOT/RAMDISK/file_contexts system_size = (int) 1610612736 tool_extensions = (str) device/rockchip/rksdk update_rename_support = (str) 1 use_set_metadata = (str) 1 using device-specific extensions in device/rockchip/rksdk building image from target_files RECOVERY... running: mkbootfs -f /tmp/targetfiles-WQjmn2/META/recovery_filesystem_config.txt /tmp/targetfiles-WQjmn2/RECOVERY/RAMDISK running: minigzip running: mkbootimg --kernel /tmp/targetfiles-WQjmn2/RECOVERY/kernel --second /tmp/targetfiles-WQjmn2/RECOVERY/resource.img --ramdisk /tmp/tmpBdTCrB --output /tmp/tmpNnUZoC running: drmsigntool /tmp/tmpNnUZoC build/target/product/security/privateKey.bin src_path: /tmp/tmpNnUZoC, private_key_path: build/target/product/security/privateKey.bin can't open file build/target/product/security/privateKey.bin! no find private key, so not sign boot.img! building image from target_files BOOT... running: mkbootfs -f /tmp/targetfiles-WQjmn2/META/boot_filesystem_config.txt /tmp/targetfiles-WQjmn2/BOOT/RAMDISK running: minigzip running: mkbootimg --kernel /tmp/targetfiles-WQjmn2/BOOT/kernel --second /tmp/targetfiles-WQjmn2/BOOT/resource.img --ramdisk /tmp/tmp6LpDeb --output /tmp/tmppqQcvT running: drmsigntool /tmp/tmppqQcvT build/target/product/security/privateKey.bin src_path: /tmp/tmppqQcvT, private_key_path: build/target/product/security/privateKey.bin can't open file build/target/product/security/privateKey.bin! no find private key, so not sign boot.img! running: imgdiff -b /tmp/targetfiles-WQjmn2/SYSTEM/etc/recovery-resource.dat /tmp/tmpD07dY4 /tmp/tmpXulEpX /tmp/tmp1qudyL Traceback (most recent call last): File "./build/tools/releasetools/ota_from_target_files", line 1059, in <module> main(sys.argv[1:]) File "./build/tools/releasetools/ota_from_target_files", line 1027, in main WriteFullOTAPackage(input_zip, output_zip) File "./build/tools/releasetools/ota_from_target_files", line 502, in WriteFullOTAPackage Item.GetMetadata(input_zip) File "./build/tools/releasetools/ota_from_target_files", line 197, in GetMetadata key, value = element.split("=") ValueError: need more than 1 value to unpack make: *** [out/target/product/rk3288/rk3288-ota-eng.wake.zip] 错误 1

python遇到IndexError: list index out of range问题,如何解决?

为什么会在代码倒数第二行出现IndexError: list index out of range错误,该如何解决?谢谢大佬 ``` for x in range(columns): for y in range(rows): if (BW[y][x] == 255): phi = ang[y][x] i = round((phi + (math.pi / 2)) / d) if (i == 0): i = 1 v = F[i] + 1 if (v > s): s = s + 1 T = [[[0 for j in range(entries)] for j in range(2)] for j in range(s)] F[i-1] = F[i-1] + 1 T[i-1][1][v] = x - xr T[i-1][2][v] = y - yr ``` ![图片说明](https://img-ask.csdn.net/upload/201903/09/1552132345_943376.jpg)

出现list index out of range错误如何解决?

4.scores.txt文件存放着某班学生的计算机成绩,包含学号、平时成绩、期末成绩三列。请根据平时成绩占40%,期末成绩占60%的比例计算总评成绩,并按学号、总评成绩两列写入另一个文件scored.txt中。同时在屏幕上输出学生总人数,按总评成绩计算90分以上、80~89分、70~79分、60~69分、60分以下各成绩区间的人数和班级总平均分(取小数点后两位)。 ``` f = open("score1.txt",encoding='gb18030', errors='ignore') a = f.readlines() del a[0] L3=[] for line in a: line=line.strip() L1=line.split() f_score=int(int(L1[1])*0.4+int(L1[2])*0.6) L3.append([L1[0],f_score]) f.close() c=[0,0,0,0] count=0 sum=0 f2 = open("score2.txt",'w') f2.write("学号 平均成绩\n"); for L2 in L3: if 90<f_score <=100: c[0] += 1 elif f_score >=80: c[1] += 1 elif f_score >=70: c[2] += 1 elif f_score >=60: c[3] += 1 else : c[4] += 1 count += 1 sum+=L2[1] f2.write(L2[0]+""+str(L2[1])+"\n") f2.close() avg_score = int(sum/count) print("学生总人数为%d,按总评成绩计,90以上%d人,80-90有%d人,70-80有%d人,60-70有%d人,60以下有%d人,班级总平均分%d分。"%d(count,c[0],c[1],c[2],c[3],c[4],avg_score)) ``` 运行出现Traceback (most recent call last): File "C:\Users\user\Desktop\T4.py", line 9, in <module> f_score=int(int(L1[1])*0.4+int(L1[2])*0.6) IndexError: list index out of range

python程序出现TypeError: 'NoneType'

最近想自学一下用python做UI,但是根据网上的教程,在.ui文件转换为.py后,无法调用自定义的函数ShowButton-click,请大大看一下 # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'test_login_form.ui' # # Created by: PyQt5 UI code generator 5.9 # # WARNING! All changes made in this file will be lost! import sys from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QApplication , QMainWindow from test_login import * class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget) self.gridLayoutWidget.setGeometry(QtCore.QRect(140, 100, 491, 321)) self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.CloseButton = QtWidgets.QPushButton(self.gridLayoutWidget) self.CloseButton.setObjectName("CloseButton") self.verticalLayout.addWidget(self.CloseButton) self.ClearButton = QtWidgets.QPushButton(self.gridLayoutWidget) self.ClearButton.setObjectName("ClearButton") self.verticalLayout.addWidget(self.ClearButton) self.lineEdit = QtWidgets.QLineEdit(self.gridLayoutWidget) self.lineEdit.setObjectName("lineEdit") self.verticalLayout.addWidget(self.lineEdit) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.ShowButton = QtWidgets.QPushButton(self.gridLayoutWidget) self.ShowButton.setObjectName("ShowButton") self.horizontalLayout.addWidget(self.ShowButton) self.ShowFormButton = QtWidgets.QPushButton(self.gridLayoutWidget) self.ShowFormButton.setObjectName("ShowFormButton") self.horizontalLayout.addWidget(self.ShowFormButton) self.gridLayout.addLayout(self.horizontalLayout, 0, 1, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) self.ClearButton.clicked.connect(self.lineEdit.clear) self.CloseButton.clicked.connect(MainWindow.close) self.ShowButton.clicked.connect(self.ShowButton_click()) self.ShowFormButton.clicked.connect(self.ShowFromButton_click()) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.CloseButton.setText(_translate("MainWindow", "Close")) self.ClearButton.setText(_translate("MainWindow", "ClearEdit")) self.ShowButton.setText(_translate("MainWindow", "这是一个用户登录界面")) self.ShowFormButton.setText(_translate("MainWindow", "登录")) def ShowButton_click(self): QtWidgets.QMessageBox.information(self.ShowButton, "标题", "这是第一个PyQt5 GUI程序") def ShowFromButton_click(slef): app = QApplication(sys.argv) loginWindow = QMainWindow() Ui_LoginWindow().setupUi(loginWindow) loginWindow.show() sys.exit(app.exec_()) if __name__ == '__main__': app = QApplication(sys.argv) mainWindow = QMainWindow() Ui_MainWindow().setupUi(mainWindow) mainWindow.show() sys.exit(app.exec_()) pass ------------------------------------------------------------------------------------ Connected to pydev debugger (build 172.4343.24) Traceback (most recent call last): File "D:\PyCham\PyCharm Community Edition 2017.2.4\helpers\pydev\pydevd.py", line 1599, in <module> globals = debugger.run(setup['file'], None, None, is_module) File "D:\PyCham\PyCharm Community Edition 2017.2.4\helpers\pydev\pydevd.py", line 1026, in run pydev_imports.execfile(file, globals, locals) # execute the script File "D:\PyCham\PyCharm Community Edition 2017.2.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:\Python36\Project\test_login_form.py", line 84, in <module> Ui_MainWindow().setupUi(mainWindow) File "D:\Python36\Project\test_login_form.py", line 59, in setupUi self.ShowButton.clicked.connect(self.ShowButton_click()) TypeError: argument 1 has unexpected type 'NoneType' Process finished with exit code 1

opencv+python人脸识别问题!请求大佬帮帮忙!

定义 def read_images(path, sz=None): 前是否需要给path赋上路径? (path = 'E:\PyCharm\rebook\data\at' def read_images(path, sz=None):) 还有这样报错,语法哪里出问题? ( File "E:/PyCharm/rebook/4load_pic.py", line 91 except IOError as (errno, strerror): ^ SyntaxError: invalid syntax ) 实在是没办法呀! 各路神仙帮帮忙! ``` import os import sys import cv2 import numpy as np def normalize(X, low, high, dtype=None): """Normalizes a given array in X to a value between low and high.""" X = np.asarray(X) minX, maxX = np.min(X), np.max(X) # normalize to [0...1]. X = X - float(minX) X = X / float((maxX - minX)) # scale to [low...high]. X = X * (high-low) X = X + low if dtype is None: return np.asarray(X) return np.asarray(X, dtype=dtype) path = 'E:\PyCharm\rebook\data\at' def read_images(path, sz=None): """Reads the images in a given folder, resizes images on the fly if size is given. Args: path: Path to a folder with subfolders representing the subjects (persons). sz: A tuple with the size Resizes Returns: A list [X,y] X: The images, which is a Python list of numpy arrays. y: The corresponding labels (the unique number of the subject, person) in a Python list. """ c = 0 X,y = [], [] for dirname, dirnames, filenames in os.walk(path): for subdirname in dirnames: subject_path = os.path.join(dirname, subdirname) for filename in os.listdir(subject_path): try: if (filename == ".directory"): continue filepath = os.path.join(subject_path, filename) im = cv2.imread(os.path.join(subject_path, filename), cv2.IMREAD_GRAYSCALE) if (im is None): print ("image " + filepath + " is none") # resize to given size (if given) if (sz is not None): im = cv2.resize(im, sz) X.append(np.asarray(im, dtype=np.uint8)) y.append(c) except IOError as (errno, strerror): print ("I/O error({0}): {1}".format(errno, strerror)) except: print ("Unexpected error:", sys.exc_info()[0]) raise c = c+1 return [X,y] if __name__ == "__main__": # This is where we write the images, if an output_dir is given # in command line: out_dir = None # You'll need at least a path to your image data, please see # the tutorial coming with this source code on how to prepare # your image data: if len(sys.argv) < 2: print ("USAGE: facerec_demo.py </path/to/images> [</path/to/store/images/at>]") sys.exit() # Now read in the image data. This must be a valid path! [X,y] = read_images(sys.argv[1]) # Convert labels to 32bit integers. This is a workaround for 64bit machines, # because the labels will truncated else. This will be fixed in code as # soon as possible, so Python users don't need to know about this. # Thanks to Leo Dirac for reporting: y = np.asarray(y, dtype=np.int32) # If a out_dir is given, set it: if len(sys.argv) == 3: out_dir = sys.argv[2] # Create the Eigenfaces model. We are going to use the default # parameters for this simple example, please read the documentation # for thresholding: model = cv2.face.createEigenFaceRecognizer() # Read # Learn the model. Remember our function returns Python lists, # so we use np.asarray to turn them into NumPy lists to make # the OpenCV wrapper happy: model.train(np.asarray(X), np.asarray(y)) # We now get a prediction from the model! In reality you # should always use unseen images for testing your model. # But so many people were confused, when I sliced an image # off in the C++ version, so I am just using an image we # have trained with. # # model.predict is going to return the predicted label and # the associated confidence: [p_label, p_confidence] = model.predict(np.asarray(X[0])) # Print it: print ("Predicted label = %d (confidence=%.2f)" % (p_label, p_confidence)) # Cool! Finally we'll plot the Eigenfaces, because that's # what most people read in the papers are keen to see. # # Just like in C++ you have access to all model internal # data, because the cv::FaceRecognizer is a cv::Algorithm. # # You can see the available parameters with getParams(): print (model.getParams()) # Now let's get some data: mean = model.getMat("mean") eigenvectors = model.getMat("eigenvectors") # We'll save the mean, by first normalizing it: mean_norm = normalize(mean, 0, 255, dtype=np.uint8) mean_resized = mean_norm.reshape(X[0].shape) if out_dir is None: cv2.imshow("mean", mean_resized) else: cv2.imwrite("%s/mean.png" % (out_dir), mean_resized) # Turn the first (at most) 16 eigenvectors into grayscale # images. You could also use cv::normalize here, but sticking # to NumPy is much easier for now. # Note: eigenvectors are stored by column: for i in xrange(min(len(X), 16)): eigenvector_i = eigenvectors[:,i].reshape(X[0].shape) eigenvector_i_norm = normalize(eigenvector_i, 0, 255, dtype=np.uint8) # Show or save the images: if out_dir is None: cv2.imshow("%s/eigenface_%d" % (out_dir,i), eigenvector_i_norm) else: cv2.imwrite("%s/eigenface_%d.png" % (out_dir,i), eigenvector_i_norm) # Show the images: if out_dir is None: cv2.waitKey(0) ```

不同数据集训练同一个CNN网络报错TypeError,如何解决?

最近在自己试着运行这个Flood-filling Networks算法,是全脑图像分割算法,基于CNN,使用Tensorflow,先附上链接: https://github.com/google/ffn 作者给的用于训练推理的一个样本数据集是FIB-25数据集,具体来说就是果蝇的切片脑图像,用于训练的数据集的维度是520\*520\*520(灰度矩阵和标签都是这个维度),我使用作者给的这个数据集运行十分顺利,但是在换用另一个数据集:CREMI数据集(也是果蝇的脑切片,维度是125\*1250\*1250)进行网络的训练的时候,报错如下: ``` Traceback (most recent call last): File "train.py", line 739, in <module> app.run(main) File "/home/.local/lib/python3.6/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/home/.local/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "train.py", line 730, in main **json.loads(FLAGS.model_args)) File "train.py", line 624, in train_ffn load_data_ops = define_data_input(model, queue_batch=1) File "train.py", line 412, in define_data_input 0])) File "/home/.local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2649, in equal "Equal", x=x, y=y, name=name) File "/home/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 609, in _apply_op_helper param_name=input_name) File "/home/.local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 60, in _SatisfiesTypeConstraint ", ".join(dtypes.as_dtype(x).name for x in allowed_list))) TypeError: Value passed to parameter 'x' has DataType uint64 not in list of allowed values: bfloat16, float16, float32, float64, uint8, int8, int16, int32, int64, complex64, quint8, qint8, qint32, string, bool, complex128 ``` 看上去问题的核心在于train.py中的 ``` **json.loads(FLAGS.model_args)) ``` 这一行,但是这里的参数FLAGS.model_args是在训练模型的时候给定的参数,不管使用哪个数据集都是一样的,我把运行训练文件的代码贴过来: ``` python train.py \ --train_coords third_party/neuroproof_examples/validation_sample/tf_record_file/tf_record.tfrecords \ #在之前的运行中生成的tfrecords文件 --data_volumes validation1:third_party/neuroproof_examples/validation_sample/grayscale_maps.h5:raw \ #灰度矩阵 --label_volumes validation1:third_party/neuroproof_examples/validation_sample/groundtruth.h5:stack \ #标签矩阵 --model_name convstack_3d.ConvStack3DFFNModel \ --model_args '{"depth": 12, "fov_size": [33, 33, 33], "deltas": [8, 8, 8]}' \ #模型参数 --image_mean 128 \ --image_stddev 33 ``` 我怎么也想不通为什么对不同的数据集,json在解码相同的model_args时会报错……?是因为CREMI数据集的三个维数不一致,我依然沿用相同的参数导致的吗(FIB-25数据集维度是520\*520\*520,CREMI数据集维度是125\*1250\*1250)? 有些茫然,感谢大家的帮助。

BERT模型训练报错:IndexError: list index out of range,求大佬指教!

![图片说明](https://img-ask.csdn.net/upload/202004/29/1588175660_746755.png) 运行结果: ``` C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) Traceback (most recent call last): File "D:/senti/code/Bert/run_classifier.py", line 1024, in <module> tf.app.run() File "C:\Users\DELL\Anaconda3\envs\tensorflow_gpu\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run _sys.exit(main(argv)) File "D:/senti/code/Bert/run_classifier.py", line 885, in main train_examples = processor.get_train_examples(FLAGS.data_dir) File "D:/senti/code/Bert/run_classifier.py", line 385, in get_train_examples self._read_tsv(os.path.join(data_dir, "train.tsv")), "train") File "D:/senti/code/Bert/run_classifier.py", line 408, in _create_examples text_a = tokenization.convert_to_unicode(line[1]) IndexError: list index out of range ```

我在用facenet模型中的classifier.py文件中训练自己的数据集的时候配置了相关参数所在的路径,但是却发生了如下报错,请问是什么原因?

作为一个刚入门的小白在这方面的学习还有许多的不懂,我在用facenet模型中的classifier.py文件中训练自己的数据集的时候配置了相关参数所在的路径,但是却发生了如下报错,请问是什么原因? ``` def parse_arguments(argv): parser = argparse.ArgumentParser() parser.add_argument('mode', type=str, choices=['TRAIN', 'CLASSIFY'], help='Indicates if a new classifier should be trained or a classification ' + 'model should be used for classification', default='TRAIN')#训练模型 parser.add_argument('data_dir', type=str, help='Path to the data directory containing aligned LFW face patches.',default='D:/pyCharm/facenet/data_dir/African_convert')#添加数据集文件夹 parser.add_argument('model', type=str, help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file',default='D:/pyCharm/facenet/20170512-110547') parser.add_argument('classifier_filename', help='Classifier model file name as a pickle (.pkl) file. ' + 'For training this is the output and for classification this is an input.' ,default='pick/classifier.pkl') parser.add_argument('--use_split_dataset', help='Indicates that the dataset specified by data_dir should be split into a training and test set. ' + 'Otherwise a separate test set can be specified using the test_data_dir option.', action='store_true') parser.add_argument('--test_data_dir', type=str, help='Path to the test data directory containing aligned images used for testing.') parser.add_argument('--batch_size', type=int, help='Number of images to process in a batch.', default=90) parser.add_argument('--image_size', type=int, help='Image size (height, width) in pixels.', default=160) parser.add_argument('--seed', type=int, help='Random seed.', default=666) parser.add_argument('--min_nrof_images_per_class', type=int, help='Only include classes with at least this number of images in the dataset', default=20) parser.add_argument('--nrof_train_images_per_class', type=int, help='Use this number of images from each class for training and the rest for testing', default=10) return parser.parse_args(argv) if __name__ == '__main__': main(parse_arguments(sys.argv[1:])) ``` 报错信息如下: usage: classifier.py [-h] [--use_split_dataset] [--test_data_dir TEST_DATA_DIR] [--batch_size BATCH_SIZE] [--image_size IMAGE_SIZE] [--seed SEED] [--min_nrof_images_per_class MIN_NROF_IMAGES_PER_CLASS] [--nrof_train_images_per_class NROF_TRAIN_IMAGES_PER_CLASS] {TRAIN,CLASSIFY} data_dir model classifier_filename classifier.py: error: the following arguments are required: mode, data_dir, model, classifier_filename ![图片说明](https://img-ask.csdn.net/upload/201910/12/1570866719_655865.jpg) ![图片说明](https://img-ask.csdn.net/upload/201910/12/1570867095_477948.jpg) 谢谢!!!

python+opencv+pyqt5 车牌批量识别报错

**单个儿车牌识别,代码运行成功,代码如下:** ``` from PyQt5 import QtCore,QtGui, QtWidgets from PyQt5.QtGui import * from PyQt5.QtCore import Qt from PyQt5.QtWidgets import * from Recognition import PlateRecognition import cv2 import sys, os, xlwt import numpy as np class Ui_MainWindow(object): def __init__(self): self.RowLength = 0 self.Data = [['文件名称', '录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']] def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(1213, 670) MainWindow.setFixedSize(1213, 670) # 设置窗体固定大小 MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.scrollArea = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea.setGeometry(QtCore.QRect(690, 10, 511, 491)) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 509, 489)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.label_0 = QtWidgets.QLabel(self.scrollAreaWidgetContents) self.label_0.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_0.setFont(font) self.label_0.setObjectName("label_0") self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents) self.label.setGeometry(QtCore.QRect(10, 40, 481, 441)) self.label.setObjectName("label") self.label.setAlignment(Qt.AlignCenter) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.scrollArea_2 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_2.setGeometry(QtCore.QRect(10, 10, 671, 631)) self.scrollArea_2.setWidgetResizable(True) self.scrollArea_2.setObjectName("scrollArea_2") self.scrollAreaWidgetContents_1 = QtWidgets.QWidget() self.scrollAreaWidgetContents_1.setGeometry(QtCore.QRect(0, 0, 669, 629)) self.scrollAreaWidgetContents_1.setObjectName("scrollAreaWidgetContents_1") self.label_1 = QtWidgets.QLabel(self.scrollAreaWidgetContents_1) self.label_1.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_1.setFont(font) self.label_1.setObjectName("label_1") self.tableWidget = QtWidgets.QTableWidget(self.scrollAreaWidgetContents_1) self.tableWidget.setGeometry(QtCore.QRect(10, 40, 651, 581)) # 581)) self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(6) self.tableWidget.setColumnWidth(0, 140) # 设置1列的宽度 self.tableWidget.setColumnWidth(1, 130) # 设置2列的宽度 self.tableWidget.setColumnWidth(2, 65) # 设置3列的宽度 self.tableWidget.setColumnWidth(3, 75) # 设置4列的宽度 self.tableWidget.setColumnWidth(4, 65) # 设置5列的宽度 self.tableWidget.setColumnWidth(5, 174) # 设置6列的宽度 self.tableWidget.setHorizontalHeaderLabels(["图片名称", "录入时间", "识别耗时", "车牌号码", "车牌类型", "车牌信息"]) self.tableWidget.setRowCount(self.RowLength) self.tableWidget.verticalHeader().setVisible(False) # 隐藏垂直表头) # self.tableWidget.setStyleSheet("selection-background-color:blue") # self.tableWidget.setAlternatingRowColors(True) self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) self.tableWidget.raise_() self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_1) self.scrollArea_3 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_3.setGeometry(QtCore.QRect(690, 510, 341, 131)) self.scrollArea_3.setWidgetResizable(True) self.scrollArea_3.setObjectName("scrollArea_3") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 339, 129)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_2.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3) self.label_3.setGeometry(QtCore.QRect(10, 40, 321, 81)) self.label_3.setObjectName("label_3") self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3) self.scrollArea_4 = QtWidgets.QScrollArea(self.centralwidget) self.scrollArea_4.setGeometry(QtCore.QRect(1040, 510, 161, 131)) self.scrollArea_4.setWidgetResizable(True) self.scrollArea_4.setObjectName("scrollArea_4") self.scrollAreaWidgetContents_4 = QtWidgets.QWidget() self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 159, 129)) self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4") self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4) self.pushButton_2.setGeometry(QtCore.QRect(20, 50, 121, 31)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4) self.pushButton.setGeometry(QtCore.QRect(20, 90, 121, 31)) self.pushButton.setObjectName("pushButton") self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents_4) self.label_4.setGeometry(QtCore.QRect(10, 10, 111, 20)) font = QtGui.QFont() font.setPointSize(11) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.pushButton.clicked.connect(self.__openimage) # 设置点击事件 self.pushButton_2.clicked.connect(self.__writeFiles) # 设置点击事件 self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.ProjectPath = os.getcwd() # 获取当前工程文件位置 def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "车牌识别系统")) self.label_0.setText(_translate("MainWindow", "原始图片:")) self.label.setText(_translate("MainWindow", "")) self.label_1.setText(_translate("MainWindow", "识别结果:")) self.label_2.setText(_translate("MainWindow", "车牌区域:")) self.label_3.setText(_translate("MainWindow", "")) self.pushButton.setText(_translate("MainWindow", "打开文件")) self.pushButton_2.setText(_translate("MainWindow", "导出数据")) self.label_4.setText(_translate("MainWindow", "命令:")) self.scrollAreaWidgetContents_1.show() # 识别 def __vlpr(self, path): PR = PlateRecognition() result = PR.VLPR(path) return result def __show(self, result, FileName): # 显示表格 self.RowLength = self.RowLength + 1 if self.RowLength > 18: self.tableWidget.setColumnWidth(5, 157) self.tableWidget.setRowCount(self.RowLength) self.tableWidget.setItem(self.RowLength - 1, 0, QTableWidgetItem(FileName)) self.tableWidget.setItem(self.RowLength - 1, 1, QTableWidgetItem(result['InputTime'])) self.tableWidget.setItem(self.RowLength - 1, 2, QTableWidgetItem(str(result['UseTime']) + '秒')) self.tableWidget.setItem(self.RowLength - 1, 3, QTableWidgetItem(result['Number'])) self.tableWidget.setItem(self.RowLength - 1, 4, QTableWidgetItem(result['Type'])) if result['Type'] == '蓝色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(3, 128, 255))) elif result['Type'] == '绿色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(98, 198, 148))) elif result['Type'] == '黄色牌照': self.tableWidget.item(self.RowLength - 1, 4).setBackground(QBrush(QColor(242, 202, 9))) self.tableWidget.setItem(self.RowLength - 1, 5, QTableWidgetItem(result['From'])) # 显示识别到的车牌位置 size = (int(self.label_3.width()), int(self.label_3.height())) shrink = cv2.resize(result['Picture'], size, interpolation=cv2.INTER_AREA) shrink = cv2.cvtColor(shrink, cv2.COLOR_BGR2RGB) self.QtImg = QtGui.QImage(shrink[:], shrink.shape[1], shrink.shape[0], shrink.shape[1] * 3, QtGui.QImage.Format_RGB888) self.label_3.setPixmap(QtGui.QPixmap.fromImage(self.QtImg)) def __writexls(self, DATA, path): wb = xlwt.Workbook(); ws = wb.add_sheet('Data'); # DATA.insert(0, ['文件名称','录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']) for i, Data in enumerate(DATA): for j, data in enumerate(Data): ws.write(i, j, data) wb.save(path) QMessageBox.information(None, "成功", "数据已保存!", QMessageBox.Yes) def __writecsv(self, DATA, path): f = open(path, 'w') # DATA.insert(0, ['文件名称','录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']) for data in DATA: f.write((',').join(data) + '\n') f.close() QMessageBox.information(None, "成功", "数据已保存!", QMessageBox.Yes) def __writeFiles(self): path, filetype = QFileDialog.getSaveFileName(None, "另存为", self.ProjectPath, "Excel 工作簿(*.xls);;CSV (逗号分隔)(*.csv)") if path == "": # 未选择 return if filetype == 'Excel 工作簿(*.xls)': self.__writexls(self.Data, path) elif filetype == 'CSV (逗号分隔)(*.csv)': self.__writecsv(self.Data, path) def __openimage(self): path, filetype = QFileDialog.getOpenFileName(None, "选择文件", self.ProjectPath, "JPEG Image (*.jpg);;PNG Image (*.png);;JFIF Image (*.jfif)") # ;;All Files (*) if path == "": # 未选择文件 return filename = path.split('/')[-1] # 尺寸适配 size = cv2.imdecode(np.fromfile(path, dtype=np.uint8), cv2.IMREAD_COLOR).shape if size[0] / size[1] > 1.0907: w = size[1] * self.label.height() / size[0] h = self.label.height() jpg = QtGui.QPixmap(path).scaled(w, h) elif size[0] / size[1] < 1.0907: w = self.label.width() h = size[0] * self.label.width() / size[1] jpg = QtGui.QPixmap(path).scaled(w, h) else: jpg = QtGui.QPixmap(path).scaled(self.label.width(), self.label.height()) self.label.setPixmap(jpg) result = self.__vlpr(path) if result is not None: self.Data.append( [filename, result['InputTime'], result['Number'], result['Type'], str(result['UseTime']) + '秒', result['From']]) self.__show(result, filename) else: QMessageBox.warning(None, "Error", "无法识别此图像!", QMessageBox.Yes) # 重写MainWindow类 class MainWindow(QtWidgets.QMainWindow): def closeEvent(self, event): reply = QtWidgets.QMessageBox.question(self, '提示', "是否要退出程序?\n提示:退出后将丢失所有识别数据", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) if reply == QtWidgets.QMessageBox.Yes: event.accept() else: event.ignore() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) MainWindow = MainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) ``` **然后我在单个识别的基础上,增加了几行代码改成批量识别,红色框的是新添加的,其余代码没有改变** ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629478_989190.png) ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629493_573295.png) **程序报错:Process finished with exit code -1073740791 (0xC0000409)** ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584629516_819110.png) 大佬们帮帮小白吧,这个增加批量识别的代码是否正确,这个错怎么改。感激不尽!

eclat算法,报语法错误python,求大神解救

eclat算法,报语法错误python,求大神解救,代入如下: import sys import time type = sys.getfilesystemencoding() from sys import argv def eclat(prefix, items): while items: i,itids = items.pop() isupp = len(itids) if isupp >= minsup: print sorted(prefix)+[i]), ':', isupp suffix = [] for j, ojtids in items: jtids = itids & ojtids if len(jtids) >= minsup: suffix.append((j,jtids)) eclat(prefix+[i], sorted(suffix, key=lambda item: len(item[1]), reverse=True)) data = {} #str1 = './datasets/T10I4D100K.dat' str1 = 'E:\pg\datasets\mushroom.dat' #minsup = int(argv[2]) #minsup = 5 ##支持度 ratio = 0.35 minsup = 8124*ratio trans = 0 #f = open(argv[1], 'r') f = open(str1) for row in f: trans += 1 for item in row.split(): if item not in data: data[item] = set() data[item].add(trans) f.close() ##计算运行的时间 start = time.clock() eclat([], sorted(data.items(), key=lambda item: len(item[1]), reverse=True)) end = time.clock() print( "run time: %f s" % (end-start)) 报错提示: ![图片说明](https://img-ask.csdn.net/upload/201811/07/1541598538_212744.png)

python3.7使用pip安装dlib失败,已使用pip安装cmake和boost

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting dlib Using cached https://pypi.tuna.tsinghua.edu.cn/packages/63/92/05c3b98636661cb80d190a5a777dd94effcc14c0f6893222e5ca81e74fbc/dlib-19.19.0.tar.gz (3.2 MB) Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error ERROR: Command errored out with exit status 1: 以下是错误原因 command: 'd:\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Ray\AppData\Local\Temp\pip-wheel-s_easgnt' cwd: C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\ Complete output (149 lines): running bdist_wheel running build running build_py package init file 'dlib\__init__.py' not found (or not a regular file) running build_ext Building extension for Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=d:\python\python37\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\lib.win-amd64-3.7 -A x64' -- Building for: Visual Studio 15 2017 -- The C compiler identification is MSVC 19.16.27034.0 -- The CXX compiler identification is MSVC 19.16.27034.0 -- Check for working C compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- Check for working C compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- Check for working CXX compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonInterp: D:/Python/Python37/python.exe (found version "3.7.6") -- Found PythonLibs: D:/Python/Python37/libs/Python37.lib -- pybind11 v2.2.2 -- Using CMake version: 3.16.3 -- Compiling dlib version: 19.19.0 -- SSE4 instructions can be executed by the host processor. -- AVX instructions can be executed by the host processor. -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void* -- Check size of void* - done -- Enabling AVX instructions -- Searching for BLAS and LAPACK -- Searching for BLAS and LAPACK -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE CUDA_TOOLKIT_ROOT_DIR not found or specified -- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5") -- DID NOT FIND CUDA -- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA -- C++11 activated. -- Configuring done -- Generating done -- Build files have been written to: C:/Users/Ray/AppData/Local/Temp/pip-install-adkry0ue/dlib/build/temp.win-amd64-3.7/Release Invoking CMake build: 'cmake --build . --config Release -- /m' 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3 版权所有(C) Microsoft Corporation。保留所有权利。 D:\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(399,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录 下,因为这可能会导致增量生成出现问题。 [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\ZERO_CHECK.vcxproj] Checking Build System D:\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(399,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目录 下,因为这可能会导致增量生成出现问题。 [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\dlib_build\dlib.vcxproj] Building Custom Rule C:/Users/Ray/AppData/Local/Temp/pip-install-adkry0ue/dlib/dlib/CMakeLists.txt base64_kernel_1.cpp bigint_kernel_1.cpp bigint_kernel_2.cpp bit_stream_kernel_1.cpp entropy_decoder_kernel_1.cpp entropy_decoder_kernel_2.cpp entropy_encoder_kernel_1.cpp entropy_encoder_kernel_2.cpp md5_kernel_1.cpp tokenizer_kernel_1.cpp unicode.cpp image_dataset_metadata.cpp mnist.cpp global_function_search.cpp kalman_filter.cpp test_for_odr_violations.cpp auto.cpp sockets_kernel_1.cpp c:\users\ray\appdata\local\temp\pip-install-adkry0ue\dlib\dlib\sockets\../dlib_basic_cpp_build_tutorial.txt(1): fatal error C1189: #error: "Don't write #include <dlib/all/source.cpp> in your code." (编译源文件 C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\dlib\sockets\sockets_kernel_1.cpp) [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\dlib_build\dlib.vcxproj] bsp.cpp dir_nav_kernel_1.cpp dir_nav_kernel_2.cpp dir_nav_extensions.cpp linker_kernel_1.cpp extra_logger_headers.cpp logger_kernel_1.cpp logger_config_file.cpp misc_api_kernel_1.cpp misc_api_kernel_2.cpp sockets_extensions.cpp sockets_kernel_2.cpp sockstreambuf.cpp sockstreambuf_unbuffered.cpp server_kernel.cpp server_iostream.cpp server_http.cpp multithreaded_object_extension.cpp threaded_object_extension.cpp threads_kernel_1.cpp threads_kernel_2.cpp threads_kernel_shared.cpp thread_pool_extension.cpp async.cpp timer.cpp stack_trace.cpp cpu_dlib.cpp tensor_tools.cpp fonts.cpp widgets.cpp drawable.cpp canvas_drawing.cpp style.cpp base_widgets.cpp gui_core_kernel_1.cpp gui_core_kernel_2.cpp png_loader.cpp save_png.cpp jpeg_loader.cpp save_jpeg.cpp Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 261, in <module> 'Topic :: Software Development', File "d:\python\python37\lib\site-packages\setuptools\__init__.py", line 145, in setup return distutils.core.setup(**attrs) File "d:\python\python37\lib\distutils\core.py", line 148, in setup dist.run_commands() File "d:\python\python37\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "d:\python\python37\lib\site-packages\wheel\bdist_wheel.py", line 223, in run self.run_command('build') File "d:\python\python37\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "d:\python\python37\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "d:\python\python37\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 135, in run self.build_extension(ext) File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 175, in build_extension subprocess.check_call(cmake_build, cwd=build_folder) File "d:\python\python37\lib\subprocess.py", line 363, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1. ---------------------------------------- ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib Running setup.py install for dlib ... error ERROR: Command errored out with exit status 1: command: 'd:\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Ray\AppData\Local\Temp\pip-record-70rug5ub\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\python\python37\Include\dlib' cwd: C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\ Complete output (151 lines): running install running build running build_py package init file 'dlib\__init__.py' not found (or not a regular file) running build_ext Building extension for Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\lib.win-amd64-3.7 -DPYTHON_EXECUTABLE=d:\python\python37\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\lib.win-amd64-3.7 -A x64' -- Building for: Visual Studio 15 2017 -- The C compiler identification is MSVC 19.16.27034.0 -- The CXX compiler identification is MSVC 19.16.27034.0 -- Check for working C compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- Check for working C compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- Check for working CXX compiler: D:/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonInterp: D:/Python/Python37/python.exe (found version "3.7.6") -- Found PythonLibs: D:/Python/Python37/libs/Python37.lib -- pybind11 v2.2.2 -- Using CMake version: 3.16.3 -- Compiling dlib version: 19.19.0 -- SSE4 instructions can be executed by the host processor. -- AVX instructions can be executed by the host processor. -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void* -- Check size of void* - done -- Enabling AVX instructions -- Searching for BLAS and LAPACK -- Searching for BLAS and LAPACK -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE CUDA_TOOLKIT_ROOT_DIR not found or specified -- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.5") -- DID NOT FIND CUDA -- Disabling CUDA support for dlib. DLIB WILL NOT USE CUDA -- C++11 activated. -- Configuring done -- Generating done -- Build files have been written to: C:/Users/Ray/AppData/Local/Temp/pip-install-adkry0ue/dlib/build/temp.win-amd64-3.7/Release Invoking CMake build: 'cmake --build . --config Release -- /m' 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3 版权所有(C) Microsoft Corporation。保留所有权利。 D:\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(399,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目 录下,因为这可能会导致增量生成出现问题。 [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\ZERO_CHECK.vcxproj] Checking Build System D:\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets(399,5): warning MSB8029: 中间目录或输出目录无法驻留在临时目 录下,因为这可能会导致增量生成出现问题。 [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\dlib_build\dlib.vcxproj] Building Custom Rule C:/Users/Ray/AppData/Local/Temp/pip-install-adkry0ue/dlib/dlib/CMakeLists.txt base64_kernel_1.cpp bigint_kernel_1.cpp bigint_kernel_2.cpp bit_stream_kernel_1.cpp entropy_decoder_kernel_1.cpp entropy_decoder_kernel_2.cpp entropy_encoder_kernel_1.cpp entropy_encoder_kernel_2.cpp md5_kernel_1.cpp tokenizer_kernel_1.cpp unicode.cpp image_dataset_metadata.cpp mnist.cpp global_function_search.cpp kalman_filter.cpp test_for_odr_violations.cpp auto.cpp sockets_kernel_1.cpp c:\users\ray\appdata\local\temp\pip-install-adkry0ue\dlib\dlib\sockets\../dlib_basic_cpp_build_tutorial.txt(1): fatal error C1189: #error: "Don't write #include <dlib/all/source.cpp> in your code." (编译源文件 C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\dlib\sockets\sockets_kernel_1.cpp) [C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\build\temp.win-amd64-3.7\Release\dlib_build\dlib.vcxproj] bsp.cpp dir_nav_kernel_1.cpp dir_nav_kernel_2.cpp dir_nav_extensions.cpp linker_kernel_1.cpp extra_logger_headers.cpp logger_kernel_1.cpp logger_config_file.cpp misc_api_kernel_1.cpp misc_api_kernel_2.cpp sockets_extensions.cpp sockets_kernel_2.cpp sockstreambuf.cpp sockstreambuf_unbuffered.cpp server_kernel.cpp server_iostream.cpp server_http.cpp multithreaded_object_extension.cpp threaded_object_extension.cpp threads_kernel_1.cpp threads_kernel_2.cpp threads_kernel_shared.cpp thread_pool_extension.cpp async.cpp timer.cpp stack_trace.cpp cpu_dlib.cpp tensor_tools.cpp fonts.cpp widgets.cpp drawable.cpp canvas_drawing.cpp style.cpp base_widgets.cpp gui_core_kernel_1.cpp gui_core_kernel_2.cpp png_loader.cpp save_png.cpp jpeg_loader.cpp save_jpeg.cpp Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 261, in <module> 'Topic :: Software Development', File "d:\python\python37\lib\site-packages\setuptools\__init__.py", line 145, in setup return distutils.core.setup(**attrs) File "d:\python\python37\lib\distutils\core.py", line 148, in setup dist.run_commands() File "d:\python\python37\lib\distutils\dist.py", line 966, in run_commands self.run_command(cmd) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "d:\python\python37\lib\site-packages\setuptools\command\install.py", line 61, in run return orig.install.run(self) File "d:\python\python37\lib\distutils\command\install.py", line 545, in run self.run_command('build') File "d:\python\python37\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "d:\python\python37\lib\distutils\command\build.py", line 135, in run self.run_command(cmd_name) File "d:\python\python37\lib\distutils\cmd.py", line 313, in run_command self.distribution.run_command(command) File "d:\python\python37\lib\distutils\dist.py", line 985, in run_command cmd_obj.run() File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 135, in run self.build_extension(ext) File "C:\Users\Ray\AppData\Local\Temp\pip-install-adkry0ue\dlib\setup.py", line 175, in build_extension subprocess.check_call(cmake_build, cwd=build_folder) File "d:\python\python37\lib\subprocess.py", line 363, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1. ---------------------------------------- ERROR: Command errored out with exit status 1: 'd:\python\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ray\\AppData\\Local\\Temp\\pip-install-adkry0ue\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Ray\AppData\Local\Temp\pip-record-70rug5ub\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\python\python37\Include\dlib' Check the logs for full command output.

linux 下socket编程,客户端连接服务器失败

最近因为课程需要学习socket网络编程,运行的时候客户端无法与服务器建立连接,请原谅菜鸟没有积分,希望各位大佬给点帮助,解决下问题 这个是运行报错的截图 ![图片说明](https://img-ask.csdn.net/upload/201910/26/1572069361_597125.png) 以下是按照课本上编写的代码 客户端client.c ``` #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #define PROTOPORT 5188 extern int errno; char localhost[] = "localhost"; int main(int argc, char* argv[]) { struct hostent *ptrh; struct sockaddr_in servaddr; int sockfd; int port; char* host; int n; char buf[1000]; memset((char*)&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; if(argc > 2){ port = atoi(argv[2]); }else{ port = PROTOPORT; } if(port > 0){ servaddr.sin_port = htons((uint16_t)port); }else{ fprintf(stderr, " bad port number %s\n", argv[2]); exit(1); } if(argc > 1){ host = argv[1]; }else{ host = localhost; } ptrh = gethostbyname(host); if((char*)ptrh == NULL){ fprintf(stderr, " invalid host: %s\n", host); exit(1); } memcpy(&servaddr.sin_addr, ptrh->h_addr_list[0], ptrh->h_length); sockfd = socket(AF_INET, SOCK_STREAM, 0); if(sockfd > 0){ fprintf(stderr, " socket creation failed\n"); exit(1); } //请求连接到服务器 if(connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr))){ fprintf(stderr, "connect failed\n"); exit(1); } //从服务器读取数据,显示到用户屏幕上 n = recv(sockfd, buf, sizeof(buf), 0); while(n > 0){ write(1, buf, n); n = recv(sockfd, buf, sizeof(buf), 0); } //关闭连接 close(sockfd); //退出 exit(0); return 0; } ``` 服务器端server.c ``` #include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <string.h> #include <netinet/in.h> #include <netdb.h> #include <stdlib.h> #include <unistd.h> #define PROTOPORT 5188 #define QLEN 6 int visits = 0; int main(int argc, char * argv[]) { struct sockaddr_in servaddr; //存放服务器网络地址结构 struct sockaddr_in clientaddr; //存放客户机网络地址结构 int listenfd; int clientfd; int port; int alen; char buf[1000]; memset((char*)& servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = INADDR_ANY; if(argc >1){ port = atoi(argv[1]); }else{ port = PROTOPORT; } if(port > 0){ servaddr.sin_port = htons((uint16_t)port); }else{ fprintf(stderr, " bad port nuber %s\n", argv[1]); exit(1); } listenfd = socket(AF_INET, SOCK_STREAM, 0); if(listenfd < 0){ fprintf(stderr, "socket creation failed\n"); exit(1); } if(bind(listenfd, (struct sockaddr*) & servaddr, sizeof(servaddr)) < 0){ fprintf(stderr, " bind failed\n"); exit(1); } if(listen(listenfd, QLEN) < 0){ fprintf(stderr, "listen filed\n"); exit(0); } while(1) { alen = sizeof(clientaddr); if((clientfd = accept(listenfd, (struct sockaddr*) & clientaddr, (socklen_t*)&alen)) < 0){ fprintf(stderr, "accept failed\n"); exit(1); } visits++; sprintf(buf, "this server has been contacted %d time \n", visits); send(clientfd, buf, strlen(buf), 0); close(clientfd); } return 0; } ```

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

百度工程师,获利10万,判刑3年!

所有一夜暴富的方法都写在刑法中,但总有人心存侥幸。这些年互联网犯罪高发,一些工程师高技术犯罪更是引发关注。这两天,一个百度运维工程师的案例传遍朋友圈。1...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

实时更新:计算机编程语言排行榜—TIOBE世界编程语言排行榜(2020年6月份最新版)

内容导航: 1、TIOBE排行榜 2、总榜(2020年6月份) 3、本月前三名 3.1、C 3.2、Java 3.3、Python 4、学习路线图 5、参考地址 1、TIOBE排行榜 TIOBE排行榜是根据全世界互联网上有经验的程序员、课程和第三方厂商的数量,并使用搜索引擎(如Google、Bing、Yahoo!)以及Wikipedia、Amazon、YouTube统计出排名数据。

阿里面试官让我用Zk(Zookeeper)实现分布式锁

他可能没想到,我当场手写出来了

立即提问