从matplotlib和噪音获取'模块没有属性'

问题描述 投票:1回答:1

我正在使用Python 3.7.4,带有matplotlib 3.2.1的Windows 10,图像1.5.31,噪声1.2.2,枕头7.1.2,并试图使此代码正常工作

import noise
import numpy as np
import matplotlib
from mpl_toolkits.mplot3d import axes3d

shape = (50,50)
scale = 100.0
octaves = 6
persistence = 0.5
lacunarity = 2.0

world = np.zeros(shape)
for i in range(shape[0]):
    for j in range(shape[1]):
        world[i][j] = noise.pnoise2(i/scale,
                                    j/scale,
                                    octaves=octaves,
                                    persistence=persistence,
                                    lacunarity=lacunarity,
                                    repeatx=1024,
                                    repeaty=1024,
                                    base=42)

plt.imshow(world,cmap='terrain')

当我运行它时,我得到

AttributeError: module 'matplotlib' has no attribute 'pyplot'

并且如果我将matplotlib的导入(带或不带Agg线更改为],则>]

import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

我知道

File "C:\Users\chris\AppData\Roaming\Python\Python37\site-packages\PIL\Image.py", line 93, in <module>
    from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\chris\AppData\Roaming\Python\Python37\site-packages\PIL\__init__.py)

我也得到了

AttributeError: module 'noise' has no attribute 'pnoise2'

我不知道这是翻译问题还是什么

我正在使用Python 3.7.4,带有matplotlib 3.2.1的Windows 10,图像1.5.31,噪波1.2.2,枕头7.1.2,并试图使此代码正常工作,将噪波导入numpy用作np导入matplotlib来自...

python matplotlib python-import noise
1个回答
0
投票

btw似乎这是conda软件包与非conda软件包冲突的问题。当我卸载conda时,现在可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.