简体   繁体   English

通过 Python 将 CSV 导入 Power BI 时出现“访问被拒绝”错误

[英]"Access is denied" error while importing CSV to Power BI via Python

I'm trying to integrate python into my Power BI workflow.我正在尝试将 python 集成到我的 Power BI 工作流中。 I was following this tutorial on the Datacamp website , but I'm having trouble importing a dataset.在 Datacamp 网站上关注本教程,但在导入数据集时遇到问题。

I've opened the python scripting area, and my code is very simple:我打开了python脚本区,我的代码很简单:

import pandas as pd

print("Hello world")

dataset = pd.read_csv("sandbox\\data_science_practice\\introduction-to-python-in-power-bi\\Datasets\\consume.csv")

print(dataset)

Note: I've trimmed off the first part of the path for privacy注意:我已经修剪了隐私路径的第一部分

I've run the code snippet in Visual Studio Code with no issue.我已经在 Visual Studio Code 中运行了代码片段,没有任何问题。 In Power BI, however, I'm hit with this error:然而,在 Power BI 中,我遇到了这个错误:

在此处输入图像描述

Can anyone help with what permissions it's referring to?任何人都可以帮助解决它所指的权限吗?

If the same code runs well in Visual Studio Code, but not in Power BI, it is likely a firewall issue, specially because you can read "Unable to connect" on that error message.如果相同的代码在 Visual Studio Code 中运行良好,但在 Power BI 中运行不佳,则可能是防火墙问题,特别是因为您可以在该错误消息中看到“无法连接”。

So, to test this, disable temporarily your firewall and retry.因此,要对此进行测试,请暂时禁用防火墙并重试。 If it works, you just need to add a permission to your firewall, to allow connections from Power BI.如果可行,您只需向防火墙添加权限,以允许来自 Power BI 的连接。

Figured out the issue.想通了这个问题。 I had installed python from the Microsoft store as per the suggestion for VS code, but while it worked really well with VS Code, it didn't work well with Power BI.我已经按照 VS 代码的建议从 Microsoft 商店安装了 python,但是虽然它在 VS Code 上运行得非常好,但在 Power BI 上运行得并不好。

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

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