AttributeError:模块“numpy”没有属性“bool”,

khbbv19g  于 12个月前  发布在  其他
关注(0)|答案(2)|浏览(292)
>>> import glumpy
/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/gloo/variable.py:82: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
  gl.GL_BOOL         : ( 1, gl.GL_BOOL,         np.bool),
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/__init__.py", line 7, in <module>
    from . import app
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/app/__init__.py", line 23, in <module>
    from . console import Console
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/app/console.py", line 7, in <module>
    from glumpy import gl, glm, gloo
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/gloo/__init__.py", line 7, in <module>
    from . program import Program
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/gloo/program.py", line 16, in <module>
    from . variable import gl_typeinfo, Uniform, Attribute
  File "/home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/gloo/variable.py", line 82, in <module>
    gl.GL_BOOL         : ( 1, gl.GL_BOOL,         np.bool),
  File "/home/mona/.local/lib/python3.10/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?

字符串
我更改了以下文件行(clean-pvnet) mona@ada:~/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy$ vi gloo/variable.py
bool gl.GL_BOOL 1 gl.GL_BOOL np.bool

bool gl.GL_BOOL 1 gl.GL_BOOL np.bool_
同样的错误。
尽管打开了一个新的终端选项卡和conda activate clean-pvnet,但似乎模块没有重新加载。

92dk7w1h

92dk7w1h1#

更新

glumpy已更新,请执行

pip install glumpy==1.2.1

字符串

老答案

潜在的问题是,glumpy在其需求中只有numpy,而实际上,它应该是numpy<1.24,因此一种解决方案也可以是只降级numpy。

pip/conda install numpy<1.24

6qfn3psc

6qfn3psc2#

我只按照教程将其中一个np.bool转换为np.bool_。我搜索了所有的np.bool,并以类似的方式转换它们,错误消失了。

(clean-pvnet) mona@ada:~/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy$ rg np.bool_
gloo/variable.py
22:bool        gl.GL_BOOL         1  gl.GL_BOOL         np.bool_
23:bvec2       gl.GL_BOOL_VEC2    2  gl.GL_BOOL         np.bool_
24:bvec3       gl.GL_BOOL_VEC3    3  gl.GL_BOOL         np.bool_
25:bvec4       gl.GL_BOOL_VEC4    4  gl.GL_BOOL         np.bool_
82:    gl.GL_BOOL         : ( 1, gl.GL_BOOL,         np.bool_),
83:    gl.GL_BOOL_VEC2    : ( 2, gl.GL_BOOL,         np.bool_),
84:    gl.GL_BOOL_VEC3    : ( 3, gl.GL_BOOL,         np.bool_),
85:    gl.GL_BOOL_VEC4    : ( 4, gl.GL_BOOL,         np.bool_),

字符串

相关问题