繁体   English   中英

为什么我不能从 Plotly 写入 /var/www/html/index.html?

[英]why can't I write to /var/www/html/index.html from Plotly?

我正在使用 Raspberry Pi Zero W 记录来自 BME280 传感器的数据。我将数据编译到一个文本文件中,然后使用 Plotly 将其可视化。 我想将输出写入 /var/www/html/index.html 以便 Apache 可以在我的网络上为该图提供服务。 这是一些非常精简的代码。

import plotly.graph_objs as go
import plotly.offline as offline
import numpy as np

N = 1000
t = np.linspace(0, 10, 100)
y = np.sin(t)

fig = go.Figure(data=go.Scatter(x=t, y=y, mode='markers'))

fig.write_html('/var/www/html/index.html')

这抛出:

PermissionError: [Errno 13] 权限被拒绝: '/var/www/html/index.html'

我已按照本指南中的说明更改 /var/www/html 的权限和所有权。 我也尝试过更改文件本身的所有权但没有成功。 有人能告诉我我需要做什么才能从 Python 写入该文件吗?

我发现如果我以 root 身份运行脚本,文件就会被写入,所以我已经在 root crontab 中安排了它并且它工作正常。

我仍然想了解为什么在更改文件的所有权限和所有权后它不起作用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM