windows下pip换源与from google.protobuf.pyext import _message,使用tensorflow出现 ImportError: DLL load failed

pip换源

原来在学校用有ipv6的清华源,回家之后速度实在捉急想换成阿里源,很多教程推荐了直接在user目录中创建一个pip目录,再新建文件pip.ini。

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

但是使用之后并没有效果,直到看到这一篇文章
要在%APPDATA%下新建上述文件,后解决,因为家里电脑环境配置比较早,目前还不清楚为何会这样,先记录下来以后搞清楚原因再来写上

from google.protobuf.pyext import _message

报了ImportError: DLL load failed的错误,原因有很多,往上看是一个 from google.protobuf.pyext import _message的错误,应该是protobuf版本的问题
在自动安装了tensorflow时, protobuf安装的是最新版本3.6.1, 出现了不兼容的问题。
更换为 protobuf 3.6.0即可(pip install protobuf==3.6.0),安装后会出现警告,不用管他
参考链接:https://blog.csdn.net/u012193416/article/details/86301899

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]: 这个错误是由于在导入tensorflow包时出现了问题。可能是由于tensorflowprotobuf版本不兼容导致的。你可以尝试检查一下protoc和protobuf的版本是否一致,并确保它们是兼容的。你可以在Anaconda Prompt中使用命令`protoc --version`和`pip show protobuf`来查看它们的版本。如果版本不一致,你可以尝试安装相同版本的protobuf来解决问题。如果版本一致但问题仍然存在,你可以尝试下面的解决方法。 引用\[2\]: 另一个可能的解决方法是在源文件中添加一行代码。你可以找到`google/protobuf/internal/container.py`文件,并在其中添加以下代码:`from collections.abc import MutableMapping`。这个代码的作用是导入`MutableMapping`类,以解决`AttributeError: module 'google.protobuf.internal.containers' has no attribute 'MutableMapping'`错误。 引用\[3\]: 这个错误可能是由于protobuf版本过低或者protobuf只支持Python 2.x导致的。你可以尝试使用`pip install protobuf-py3`和`pip install --upgrade protobuf`命令来安装或升级protobuf库。这样可以确保你使用的是适用于Python 3的protobuf版本。如果问题仍然存在,你可以尝试其他解决方法或者查找更多关于这个错误的信息来解决问题。 综上所述,你可以尝试检查和更新protobuf版本,或者在源文件中添加必要的代码来解决这个错误。 #### 引用[.reference_title] - *1* *3* [【ERROR】TypeError: expected bytes, Descriptor found](https://blog.csdn.net/ccbrid/article/details/103425627)[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^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [问题解决 AttributeError: module ‘google.protobuf.internal.containers‘ has no attribute ...](https://blog.csdn.net/qq_43865022/article/details/124402242)[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^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值