导入Anaconda中的第三方库运行时报错:ImportError: Missing required dependencies ['pandas']

今天碰到一个大坑,花了大半天才搞明白问题出在哪来。事情的经过是这样的:博主下午手贱把已将装好anaconda2给卸载了(同时装了2和3),然后再次安装anconda2后,却发现配置完pycharm的解释器后,代码报错::ImportError: DLL load failed:“xxxx模块没发现”或者ImportError: Missing required dependencies [‘XXX’]。当时就很郁闷,因为整个project已经引入所需的解释器了,即anaconda2集成的许多第三方库,这里面又提示的缺失模块:如pandas等等。但是为什么这里还报缺失模块的错误。如果你碰到的情景跟我类似,不妨往这个方向去考虑解决办法!
下面是保留的报错信息:

D:\Anaconda\envs\py2\python.exe E:/PythonTest/NaiveBayesian.py
Traceback (most recent call last):
  File "E:/PythonTest/NaiveBayesian.py", line 2, in <module>
    import numpy as np
  File "D:\Anaconda\envs\py2\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "D:\Anaconda\envs\py2\lib\site-packages\numpy\core\__init__.py", line 71, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using D:\Anaconda\envs\py2\python.exe),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions 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

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

根据上面的信息,基本就能锁定问题了,后来证实的确是环境变量问题!
这种问题一般是由于环境变量的配置问题导致程序在引用模块的时候发生了错误。所以先检查下你新安装的anaconda(或者其他软件)有没有配置环境变量,像我这种同时使用anaconda2和anaconda3的情况,你还要考虑两种不同版本的环境变量在引用的时候会不会发生冲突。因为毕竟两个版本许多指令都一样。最终我是将两个版本的环境变量都加上后才把问题解决了。

操作过程如下:
添加三个环境变量:
在这里插入图片描述
下面是我之前的anaconda3的环境变量
在这里插入图片描述
还有最后一句话,对环境变量进行修改后记得重启电脑,不然会出现许多意想不到问题哦!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值