AttributeError: module 'xlrd' has no attribute 'open_book'怎么改
时间: 2023-09-11 20:07:17 浏览: 65
在xlrd 2.0.0版本中,`open_book()`方法已经被弃用。你可以使用`open_workbook()`方法替换它。请尝试以下代码:
```python
import xlrd
workbook = xlrd.open_workbook('example.xlsx')
```
如果你使用的是旧版本的xlrd,可以尝试升级到2.0.0版本。如果不能升级,可以使用以下代码:
```python
import xlrd
workbook = xlrd.open_workbook(filename='example.xlsx', on_demand=True)
```
在旧版本中,`open_book()`方法需要指定`filename`参数,而且还需要设置`on_demand=True`参数。
相关问题
AttributeError:module 'xlrd'has no attribute 'open_workbook'
这个错误提示通常表示你使用的xlrd模块中并没有名为open_workbook的属性或方法。这可能是因为你的xlrd模块版本过低,或者你没有正确地安装该模块。
如果你确认已经正确地安装了xlrd模块,并且仍然遇到这个错误,那么可能是因为你在代码中写错了该模块的调用方式。可以尝试检查你的代码并确保你正确地调用了open_workbook方法。
AttributeError: module pynvml has no attribute _nvmlGetFunctionPointer
引用\[1\]:在编写Python脚本过程中,你遇到了一个报错:AttributeError: 'module' object has no attribute 'core'。这个错误通常是由于命名冲突或者版本不兼容引起的。引用\[2\]:参照通用解决方法并没有解决你的报错,最后你发现自己新建的Python文件名字和内置的函数名冲突,修改了Python文件的名字后问题得到解决。引用\[3\]:在训练YOLO模型时,你遇到了AttributeError: module pynvml has no attribute _nvmlGetFunctionPointer的报错。后来发现这是由于numpy版本问题引起的,因为在NumPy 1.20中已经弃用了numpy.int,在NumPy 1.24中已经删除了。你可以通过重新安装numpy或者修改代码来解决这个问题。
综上所述,你遇到的AttributeError: module pynvml has no attribute _nvmlGetFunctionPointer的报错可能是由于numpy版本不兼容引起的。你可以尝试重新安装numpy或者修改代码来解决这个问题。
#### 引用[.reference_title]
- *1* *2* [【Python 脚本报错】AttributeError:‘module‘ has no attribute ‘xxx‘的解决方法](https://blog.csdn.net/qq_35091353/article/details/115609471)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [AttributeError: module numpy has no attribute int .报错解决方案](https://blog.csdn.net/weixin_46669612/article/details/129624331)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]