报错信息:
ImportError: PyCapsule_Import could not import module "datetime"
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\Code\Python\Note\cluster.py", line 14, in <module>
import numpy as np
File "C:\Users\d\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\Users\d\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.7 from "C:\Users\d\AppData\Local\Continuum\anaconda3\envs\env_python374_v2\python.exe"
* The NumPy version is: "1.19.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: PyCapsule_Import could not import module "datetime"
解决办法:
同一个代码,在Spyder中运行没问题,通过命令行就报错。一开始还真以为是numpy版本问题,后来搜索到原来是因为同文件下有“datetime.py”,和module datetime同名,导致系统会不知道执行哪一个,就报了导入的错误,把自己的datetime.py文件改了个名就好了