from openpyxl import load_workbook
wb = load_workbook(filename = output_filename)
ws = wb.get_active_sheet()
ws.cell(row=1,column=1).value = "write_lol"
wb.save(output_filename)
这会产生以下错误。节目的其他部分并不重要。这是一个相对简单的程序,应该工作。我已经安装好模块了。使用PyCharm
File "C:\Users\M0182965\Desktop\pythonProject\main.py", line 646, in <module>
from openpyxl import load_workbook
File "C:\Users\M0182965\PycharmProjects\pythonProject\venv\lib\site-packages\openpyxl\__init__.py", line 4, in <module>
from openpyxl.compat.numbers import NUMPY, PANDAS
File "C:\Users\M0182965\PycharmProjects\pythonProject\venv\lib\site-packages\openpyxl\compat\__init__.py", line 5, in <module>
from .strings import (
File "C:\Users\M0182965\PycharmProjects\pythonProject\venv\lib\site-packages\openpyxl\compat\strings.py", line 10, in <module>
from .numbers import NUMERIC_TYPES
File "C:\Users\M0182965\PycharmProjects\pythonProject\venv\lib\site-packages\openpyxl\compat\numbers.py", line 49, in <module>
numpy.float,
File "C:\Users\M0182965\PycharmProjects\pythonProject\venv\lib\site-packages\numpy\__init__.py", line 338, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` 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: 'cfloat'?
D_Lib: debug printing for files [.*] and level [100] is turned on
D_Lib: debug printing for files [.*] and level [200] is turned on
D_Lib: debug printing for files [.*] and level [300] is turned on
1条答案
按热度按时间pzfprimi1#
你在numpy版本中有一个冲突,你试图实现的方法是np.float,该功能已被弃用,并引入了一些更高级的功能。你可以使用python的float或者把你的numpy版本调低来使用它。基本上这是openpyxl本身的包问题,你必须去调试日志中提到的文件,在那里你必须实现浮点冲突修复。