Flask无法找到app文件

时间:2016-06-06 05:39:13

标签: python flask

在官方Flask教程的Step 2中,Flask无法找到我的应用文件,因为它正在../venv/Scripts/而不是我运行命令的位置。我怎么能告诉Flask在正确的地方看?

(venv) C:\Users\TomV\Codes\flaskr_tutorial>flask run
 * Serving Flask app "flaskr"
 * Forcing debug mode on
 * Restarting with stat
c:\users\tomv\codes\flaskr_tutorial\venv\scripts\python.exe: can't open file 'C:\Users\TomV\Codes\flaskr_tutorial\venv\Scripts\flask': [Errno 2] No such file or directory

2 个答案:

答案 0 :(得分:9)

根据这个github问题似乎存在一个错误:

https://github.com/pallets/flask/issues/1829

作为一种解决方法,你可以做到

>python -m flask run

初始化数据库时,您也可以在本教程后面使用>python -m flask initdb(步骤4)。

答案 1 :(得分:0)

当您运行“ python app.py”时,您可以为app.py提供完整路径

import numpy as np
from skimage.draw import polygon_perimeter
bounding_boxes = []

for contour in contours:
    Xmin = np.min(contour[:,0])
    Xmax = np.max(contour[:,0])
    Ymin = np.min(contour[:,1])
    Ymax = np.max(contour[:,1])

bounding_boxes.append([Xmin, Xmax, Ymin, Ymax])
with_boxes  = np.copy(gray_img)
for box in bounding_boxes:
    #[Xmin, Xmax, Ymin, Ymax]
    r = [box[0],box[1],box[1],box[0], box[0]]
    c = [box[3],box[3],box[2],box[2], box[3]]
    rr, cc = polygon_perimeter(r, c, with_boxes.shape)
    with_boxes[rr, cc] = 1 #set color white
plt.imshow(with_boxes, interpolation='nearest', cmap=plt.cm.gray)
plt.show()