【发布时间】:2020-03-19 08:45:01
【问题描述】:
我在 WSL 的 Ubuntu 环境中使用 python 编写了一个脚本。
我在 Windows 中下载了 firebase 的私钥“serviceAccountKey.json”,然后将其移动到我在 wsl 中的工作目录中。 (使用'mv mnt/c/Users/Yiu/Downloads/serviceAccountKey.json ~/projects/scrape')。现在,我正在尝试将该文件传递给 Certificate() 但我得到一个文件未找到错误。
我做了一些研究,发现权限可能存在一些问题,但文件都有读取、写入和执行权限。
脚本:
import requests
from bs4 import BeautifulSoup
import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate("~/projects/scrape/serviceAccountKey.json")
firebase_admin.initialize_app(cred)
db = firestore.client()
如何摆脱文件未找到错误?
【问题讨论】:
-
你的路径正确吗?
-
你检查你运行的是哪个
python吗?在 WSL 中你可能偶尔会运行 Windowspython,它只是不理解带有 ~ 的路径。 -
是的,我的路径是正确的
-
如何检查我正在运行的 python?
-
> which python
标签: python firebase google-cloud-firestore windows-subsystem-for-linux