不能从hdfscli导入Python hdfs客户端或配置模块。

huangapple go评论76阅读模式
英文:

Cannot import Python hdfs client or config modules from hdfscli

问题

我尝试创建一个使用hdfscli库的Python 3 HDFS客户端根据文档我尝试了以下代码

```python
import hdfs

client = hdfs.config.Config().get_client("dev")

但出现了AttributeError: module 'hdfs' has no attribute 'config'错误。

我还尝试了以下代码:

import hdfs

client = hdfs.client.InsecureClient("http://<target/IP/address>")

但出现了AttributeError: module 'hdfs' has no attribute 'client'错误。

我还尝试了from hdfs import clientfrom hdfs import config,但分别出现了ModuleNotFoundError: No module named 'ConfigParser'ImportError: cannot import name 'config' from 'hdfs'错误。

我使用poetry进行包管理,并尝试重新运行了poetry lockpoetry install,但都没有成功。我的pyproject.toml文件中列出了hdfs = "^1.0.1"。我还有一个hdfscli.cfg文件,位于尝试访问它的脚本的几个级别之上。


<details>
<summary>英文:</summary>

I&#39;m trying to create a Python 3 HDFS client using the hdfscli library.  Per the documentation, I&#39;ve tried 

import hdfs

client = hdfs.config.Config().get_client("dev")

which yields `AttributeError: module &#39;hdfs&#39; has no attribute &#39;config&#39;`

and I&#39;ve tried

import hdfs

client = hdfs.client.InsecureClient("http://<target/IP/address/>")

which yields `AttributeError: module &#39;hdfs&#39; has no attribute &#39;client&#39;`.  

I&#39;ve also tried `from hdfs import client` and `from hdfs import config`, which yield `ModuleNotFoundError: No module named &#39;ConfigParser&#39;` and `ImportError: cannot import name &#39;config&#39; from &#39;hdfs&#39;` respectively.

I&#39;m using poetry for package management, and I&#39;ve re-run `poetry lock` and `poetry install` to no avail.  The `pyproject.toml` file lists `hdfs = &quot;^1.0.1&quot;`.  I have a hdfscli.cfg file a couple levels up from the script that&#39;s trying to access it.

</details>


# 答案1
**得分**: 1

Running `poetry remove hdfs`, `poetry add hdfs`, `poetry lock`, and `poetry install` again seems to have resolved the issue. The `pyproject.toml` file now lists `hdfs = "^2.7.0"`, so I may have just had quite an old hdfs version.

<details>
<summary>英文:</summary>

Running `poetry remove hdfs`, `poetry add hdfs`, `poetry lock`, and `poetry install` again seems to have resolved the issue.  The `pyproject.toml` file now lists `hdfs = &quot;^2.7.0&quot;` so I may have just had quite an old hdfs version.

</details>



huangapple
  • 本文由 发表于 2023年6月6日 03:51:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409592.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定