cv2.imread正在阻止流

时间:2019-04-29 00:45:37

标签: python apache opencv wamp wsgi

我尝试使用 select count(*) from output 读取图像,但流程只是在那里阻塞并且永不返回,试图读取已经存在的文件,但是出现了同样的问题,不确定原因是什么

cv2.imread()

注释:这是一个在@app.route('/api/upload', methods=['GET', 'POST']) def upload_file(): print('request method is {}'.format(request.method)) if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: print('file not in request.files') return redirect(request.url) file = request.files['file'] if file.filename == '': print('filename is {}'.format(file.filename)) return redirect(request.url) print(file and allowed_file(file.filename)) if file and allowed_file(file.filename): print('receiving ... ', file.filename) filename = secure_filename(file.filename) ts = int(time.time()) file_name = file_name_template.format(ts, filename) print(file_name) filePath = os.path.join(app.root_path, app.config['UPLOAD_FOLDER'], file_name) file.save(filePath) print('reading image') cv2.imread(filePath) return 'done' #never executed + WAMP server

上运行的Flask应用程序

1 个答案:

答案 0 :(得分:0)

我相信这已经在另一个posting中得到了解答。另请参见http://blog.rtwilson.com/how-to-fix-flask-wsgi-webapp-hanging-when-importing-a-module-such-as-numpy-or-matplotlib/

基本上,它不是使用主解释器来运行cv2.imread,而后者在子解释器中无法正常运行。