I deploied a web app on pythonanywhere but I got this error from view.py.I tried to change SECRETS_FILE = "absolute path" but it still couldn't find .json.Does anyone who had met this error before and solved it?
from __future__ import print_function
from django.shortcuts import render
from datetime import datetime
from django.http import HttpResponse
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pandas as pd
import json
import sys
import os
#import c3pyo as c3
# Create your views here.
def welcome(request):
return render(request, 'index.html')
def questionnaire(request):
print("Current folder: " + os.getcwd())
SCOPE = ["https://spreadsheets.google.com/feeds"]
SECRETS_FILE ="My Project-XXXXXXXXX.json"
SPREADSHEET = "BackHarbor"
credentials = ServiceAccountCredentials.from_json_keyfile_name(SECRETS_FILE, scopes=SCOPE)
gc = gspread.authorize(credentials)
workbook = gc.open(SPREADSHEET)
# Get the first sheet
sheet = workbook.sheet1
data = pd.DataFrame(sheet.get_all_records())
^{pr2}$error message
无法访问您的文件“我的项目”-XXXXXXXXX.json在
尝试从“我的项目”重命名此文件-XXXXXXXXX.json“到”我的项目-XXXXXXXXX.json'
或者这可能有用我不知道
可以在空格前添加反斜杠
SECRETS_FILE ="My\ Project-XXXXXXXXX.json"
相关问题 更多 >
编程相关推荐