TypeError: makedirs() got an unexpected keyword argument 'exhist_ok'
时间: 2023-10-07 08:07:38 浏览: 318
TypeError: makedirs() got an unexpected keyword argument 'exist_ok'是一个Python错误。根据提供的引用内容,这个错误是由于使用了一个不支持exist_ok参数的makedirs函数。根据报错信息以及博主的尝试,他们尝试删除了两个py文件中的exist_ok参数,然后再次运行成功,没有报错。
对于你的问题,请尝试删除所有使用makedirs()函数时的exist_ok参数,然后再次运行程序,看是否能够解决问题。如果问题仍然存在,你可以进一步尝试检查Python版本,确保你使用的是3版本以上的Python。如果问题仍然没有解决,你可以尝试搜索相关的解决方案,或者请教其他更有经验的开发者。
相关问题
TypeError: got an unexpected keyword argument 'pos_label'
`TypeError: got an unexpected keyword argument 'pos_label'` 这是一个常见的 Python 错误,当你在调用某个函数或方法时使用了一个不存在的关键字参数 `pos_label`,但这个函数的定义中并没有接受这个参数,Python 解释器就会抛出这样的错误。`pos_label` 通常用于二分类任务中的某些库,比如 scikit-learn 中的 `sklearn.metrics.accuracy_score()` 或者一些混淆矩阵生成函数,这些函数可能期望的是 `true` 或 `first` 这样的默认值,而不是一个自定义的 `pos_label`。
例如,如果你在调用 `accuracy_score(y_true, y_pred, pos_label="my_label")` 而函数实际只接受 `y_true`、`y_pred` 这两个参数,就会出现这个错误。
TypeError: makedirs() got an unexpected keyword argument 'path'
这个错误提示通常出现在 Python 2.x 版本中。在 Python 2.x 中,`os.makedirs()` 函数不支持 `path` 参数。取而代之的是,您需要将路径作为字符串传递给 `os.makedirs()` 函数。例如:
```
import os
dir_path = '/path/to/directory'
if not os.path.exists(dir_path):
os.makedirs(dir_path)
```
如果您正在使用 Python 3.x 版本,则可以直接使用 `os.makedirs()` 函数,如下所示:
```
import os
dir_path = '/path/to/directory'
os.makedirs(dir_path, exist_ok=True)
```
在 Python 3.x 中,`os.makedirs()` 函数支持 `path` 参数,并且还支持 `exist_ok` 参数,用于指定是否应忽略目录已存在的情况。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)