[work]AttributeError: module 'pandas.core.computation' has no attribute 'express'

之前在windows下装了TensorFlow和Anaconda,运行环境是Pycharm.

开始直接在cmd下试的没问题,运行命令:pytho fileneme.py,感觉用着不方便,还是学着用PyCharm吧。不过二者遇到的问题都是一致的,可用同样方法解决

错误1:模块导入问题

正常情况下,导入各种模块、包时,在 File->Settiings->Project:project_name->Project Interpreter 中,点右上角‘+’,直接搜索安装即可。不过总是有很多问题出现,比如开始的找不到tsfresh,安装时出现错误:error:Microsoft Visual C++ 14.0 is required.其他一些模块也有这个问题。


解决办法:

法1:pycharm终端输入pip install xxx,直接安装。不行转2.

法2:网上直接下载对应的whl文件,再终端pip安装pip install xxx.whl。

 一般直接搜即可,这里给出一个地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted

 tsfresh地址:https://pypi.python.org/pypi/tsfresh

法3:将对应的包直接放在工程目录下。如:tsfresh问题,干脆把Anaconda3\Lib\site-packages下的整个tsfresh文件夹放到了工程目录下,错误消失。


错误2:AttributeError: module 'pandas.core.computation' has no attribute 'express

前面还有一堆文件文件代码定位,没截图。最后一句是AttributeError: module 'pandas.core.computation' has no attribute 'express。

解决办法:

升级dask即可,直接cmd下,pip install --upgrade dask,(Pycharm则直接在终端输入),完成后提示Successfully installed.


再运行,成功!大笑

ps: 程序文件和数据文件最好都放在工程根目录下。

D:\PythonProject\moxing1\.venv\Scripts\python.exe D:\PythonProject\moxing1\try.py 2025-08-14 12:37:47.897094: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. 2025-08-14 12:37:48.651773: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`. WARNING:tensorflow:From D:\PythonProject\moxing1\.venv\Lib\site-packages\tf_keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead. 原始数据集大小: 545 有效样本数: 545 类别权重: {0: np.float64(4.866071428571429), 1: np.float64(1.2976190476190477), 2: np.float64(1.792763157894737), 3: np.float64(0.4055059523809524)} Traceback (most recent call last): File "D:\PythonProject\moxing1\try.py", line 314, in <module> trained_model, history = train_and_evaluate() ^^^^^^^^^^^^^^^^^^^^ File "D:\PythonProject\moxing1\try.py", line 216, in train_and_evaluate y_train, y_test, class_weights) = load_and_preprocess_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\PythonProject\moxing1\try.py", line 101, in load_and_preprocess_data y_train = utils.to_categorical(y_train, NUM_CLASSES) ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'tensorflow.python.keras.utils' has no attribute 'to_categorical' Process finished with exit code 1
最新发布
08-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值