pybinding无法导入名称allow\u光栅化

2024-10-06 08:08:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我只安装了pybinding,并尝试运行这个库的文档中提出的第一个示例。在

import pybinding as pb
import numpy as np
import matplotlib.pyplot as plt
import pybinding as pb

d = 0.2  # [nm] unit cell length
t = 1    # [eV] hopping energy

# create a simple 2D lattice with vectors a1 and a2
lattice = pb.Lattice(a1=[d, 0], a2=[0, d])
lattice.add_sublattices(
    ('A', [0, 0])  # add an atom called 'A' at position [0, 0]
)
lattice.add_hoppings(
    # (relative_index, from_sublattice, to_sublattice, energy)
    ([0, 1], 'A', 'A', t),
    ([1, 0], 'A', 'A', t)
)

lattice.plot()
plt.show() 

我已经安装了文档中需要的东西(对于Windows操作系统),并且sicrpt运行得很好,直到它必须执行格子图()引发以下错误

^{pr2}$

我已经检查了matplotlib是否正确安装(我尝试了matplotlib文档中推荐的一些绘图,效果很好)。也找过档案收藏.py错误在第二行

import numpy as np
from matplotlib.collections import Collection, allow_rasterization

看着收藏.py在matplolib中搜索“allow_光栅化”时,我发现了重复的6次以下函数

@artist.allow_rasterization
def draw(self, renderer):

我对python很陌生,所以我不知道我是否在考虑我应该做什么。提前谢谢


Tags: 文档importnumpyadda2matplotliba1as
3条回答

进入文件“C:\xampp7\Python\lib\site packages\pybinding\support\收藏.py”并将命令行修改为: “从matplotlib.集合导入集合#,允许光栅化 从matplotlib.artist导入允许光栅化“

我卸载了matplotlib的2.2.2版本,安装了marplotlib的1.1.2版本。 我现在可以做put.show()

我也有同样的问题。我使用的是Linux,并且安装了pybinding包

/usr/lib/python3.6/site-packages/pybinding/support/

您可以更正更改allow_rasterization模块的导入模块、更改文件的错误学院.py

^{pr2}$

第一行来自

^{3}$

import numpy as np
from matplotlib.collections import Collection
from matplotlib.artist import allow_rasterization

您可以更正与matplotlib 1.1.2上以前版本相关的打印问题,因为现在pybinding包使用matplotlib 2.2.2。在

相关问题 更多 >