numpy: cannot import name '_distributor_init'

  这个问题网上的解决方式并不多,而且我并没有找到有效的处理方式。
  然,其实在报错的时候,它已经给出了解决方式,已经给出了!!!一定要记得仔细看,我当时是服务器上的flask项目,报错信息在 apache的error.log 中,上面给了很详细的解释和解决方式,只是我只看了最后一行……尴尬。

 Try uninstalling and reinstalling numpy.
…… - If you have already done that, then:
……   1. Check that you expected to use Python3.4 from "/var/www/flask_demo/venv/bin/python3",
…… and that you have no directories in your PATH or PYTHONPATH that can
…… interfere with the Python and numpy version "1.17.2" you're trying to use.
…… 2. If (1) looks fine, you can open a new issue at
…… https://github.com/numpy/numpy/issues.  Please include details on:
…… - how you installed Python
…… - how you installed numpy
…… - your operating system
…… - whether or not you have multiple versions of Python installed
…… - if you built from source, your compiler versions and ideally a build log
…… - If you're working with a numpy git repository, try `git clean -xdf`
…… (removes all files not under version control) and rebuild numpy.

  赶巧,我这边问题正好是第一个,项目用的依赖包是 Python3.7.4 版本的,结果运行的python却是 3.4 的,所以就报错了。卸了Python 3.4 ,重装 Python 3.7 就解决了。当然也可以改用 Python 3.4版本适配的numpy,应该也能解决问题。不过我这边其他依赖包也都是用的 Python3.7 的,所以就直接重装Python了。

参考文章:【1】python - ImportError: cannot import name _distributor_init - Stack Overflow
     【2】python - ImportError: cannot import name NUMPY_MKL - Stack Overflow
     【3】python - Numpy - ImportError: cannot import name _distributor_init - Stack Overflow
     【4】 Python导入Scipy子模块时出现问题? - 知乎

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值