Python即使已安装也无法导入“ nbt”

时间:2020-05-29 09:14:33

标签: python

我在尝试导入模块时遇到问题,提示“无法导入'nbt'”,我已重新安装它并确保我具有最新版本的pylint。但是我仍然收到错误消息。

当我尝试执行“ pip install nbt”时,它说“要求已经满足”,有人知道这个问题吗?

这是我的代码:

import io
import base64
from nbt import nbt
raw = "H4sIAAAAAAAAANWZ3XLbxhmGYSduJLWJnZn0Jz+TQVq7SSfdBFj8a6YHNEnRZAVAIiHRwIlngV0QAPGjgqAk8h56Bz1uTnrQg15BLqUX0ukHSnRki5KYWh6l9liigA/YNfA++77faovjNrl78RbHcZ/e5+7H9N5f73EPmsU0r+5tce9UZPQOt/kspmwnJaMJVP1ni9sajKdpap/krNzg7ncp9zgM1dAPqIYUUdKRpPoGIhINkBwomISSHmCBwnV7ZXHEyipmk01uo2Kn1bRkk3roexvcg0OSThn3TzbrCd7zSKDPe2kw66rwszMQUrubHGnd/HDmN7tqN4Pzzxrq7sy4UKtUZKikrtSLvHx/6meHwq7UT9mzvhhkB8dW62DmdazISqLE7riyO3RFc25lbhLMLexF3vAwcnEvteZtyU3G2G4FGI4npjOSzaQ/due9sTmnkTsPZHvoJdY8iMPnogGz3+Leo/HkKCWzTe7d3aJkG3Dw5xz//XfaoCpZPqqibfgh+Fqsv37VKWg6478W/8A9gYpmGVd8MyJ5wM6LnrxS9eRCWYtkZHRlGcc9hsJuXrE0jUfs/Ibk0qgc97v6hkWcT/hJRcqKJ0dHjJRxPuJJCW+e8rNiyv0WioogIJO4yEkK1xY5fzT10zjg40lKcjr5htuEmt1pMJ59AXf91fffhd9/lzZt07QtvtFstgcDu+9ucO9aJGPcJ3D6bBIOSeNJRnK+CPnFNOAJPmyfViVpVFUZ+9OKTTa4jaygcRizknswqi/b4DaLMh7FuUNG3C+b/caO07U6Lzr9butF097dbTedjVrA3PtNu2u9cBq73YHZsGD46RSOPpY0JoeKLiEmEAHJqhAi3zc0pGm+SIiuGgoxYIwqzhg8leyIe6h8K+rfYoHXtg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jkDJqH3epraTndmJmlqzq43l/dqrbCDPP7LlPHtMGRBtc3vFVUM+WMpmkX8+UH0iwA0LcmipghBqbMFFgHEnmkGDJxffpaA8CICnVnFJ+dWUWOwQCfOj1leFeXsm/OQBcA5UTzh44plfEDgJowvWViUI0a/uFn3v4aC1ybP9+N8tFLtayr7o359fA8eKASnxs5O1+o67kuBK7IsGcyHgBJqEpIlWUA+NXRY1TETJIMYWLvURGGtFri0LePb3F/AGiFYDRBYnAq4iTVkhopEBfyNyAr8u+v9BdCzsvCFzBt7ST/xnH5iZS6EqIZgDw8zdx4lrvM0NVtRbA+74Dm9zMTgKc6o3n8Ye9kOhC4r8loBBCwvARYk94bfSj1YeMpSvAvtLrR1FAdjfnrElySHB/9wsWzXcpVOz9fYW1AjLN/EJKOcVXFw/cK7phQ/NBsdq+10myuaeaKJRJQhLYc6RbIWaEhXdYwCggNB93Eo6fpVvxkV5Us6vPTnv0dPp71kIAAA"


def decode_inventory_data(raw):
    data = nbt.nbt.NBTFile(fileobj=io.BytesIO(base64.b64decode(raw)))
    print(data)
    return data

谢谢

1 个答案:

答案 0 :(得分:0)

python可执行文件找不到模块。

我建议这些步骤:

1)非自愿超越

检查您是否没有保存任何文件名为 nbt.py

的文件

2)哪个口译员?它从哪里加载模块?

将此行添加到脚本中:

导入系统

打印(sys.executable)

print(sys.path)

输出是

  • python解释器位置
  • 要在其中加载模块的目录

如果已安装模块,则可以在文件系统上搜索它。 例如linux

找到/ -name nbt.py

其位置应为之前列出的位置之一。

3)在特定目录中查找

您可以建议Python在其他目录中查找模块,并将目录添加到此环境变量中:

PYTHONPATH

请参阅Python文档,第1.2节环境变量

https://docs.python.org/3/using/cmdline.html