运行一段程序的时候会提示:
Traceback (most recent call last):
File "sigmoid.py", line 3, in
import matplotlib.pylab as plt
File "D:\software\python\python37\lib\site-packages\matplotlib\__init__.py", line 205, in
_check_versions()
File "D:\software\python\python37\lib\site-packages\matplotlib\__init__.py", line 199, in _check_versions
module = importlib.import_module(modname)
File "D:\software\python\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'dateutil'
但是如果这时运行包下载时,会提示:
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: python-dateutil in d:\software\python\anaconda\lib\site-packages (2.8.0)
Requirement already satisfied: six>=1.5 in d:\software\python\anaconda\lib\site-packages (from python-dateutil) (1.12.0) (1.12.0)
解决办法:
可以根据提示,我们知道,这是由于已经下载了anaconda,而在anaconda里已经默认安装了很多库,这就导致了安装库文件时其实已经存在了。
因此,只需要找到已经安装的包的位置,将处于该目录下的包拷贝到我们安装python的库文件目录下即可。
python库文件的目录为:
python\lib\site-packages
比如本例是由于安装了anaconda,因此将anaconda\lib\site-packages目录下的库文件拷贝到python\lib\site-packages即可。