【发布时间】:2020-04-18 13:42:36
【问题描述】:
我的代码行之一是
import yaml
使用pip install pyyaml安装在python 3.7上
出现以下错误
Traceback(最近一次调用最后一次):
文件 "C:/code/EPMD/Kodex/Applications/EPMD-Software/Sandbox/peer_sharing_send_rate.py", 第 1 行,在 从 TestPeer.TestPeerChangingSendRate 导入 TestPeerChangingSendSpeed 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\TestPeer\TestPeerChangingSendRate.py”,
第 1 行,在 从 .TestPeer 导入 TestPeer 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\TestPeer\TestPeer.py”,
第 4 行,在 从 BaseProcess.ZmqPeerClass 导入 ZmqPeer 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\BaseProcess\ZmqPeerClass.py”,
第 2 行,在 从 .ZmqPublisherClass 导入 ZmqPublisher 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\BaseProcess\ZmqPublisherClass.py”,
第 10 行,在 从 。导入 ZmqProcessClass 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\BaseProcess\ZmqProcessClass.py”,
第 5 行,在 从 .ConfigBaseClass 导入 ConfigBase 文件“C:\code\EPMD\Kodex\Applications\EPMD-Software\BaseProcess\ConfigBaseClass.py”,
第 3 行,在 导入yaml 文件“C:\code\EPMD\Kodex\venv\lib\site-packages\yaml__init__.py”,第 9 行,在 从 .dumper 导入 * 文件“C:\code\EPMD\Kodex\venv\lib\site-packages\yaml\dumper.py”,第 6 行,在 从 .representer 导入 * 文件“C:\code\EPMD\Kodex\venv\lib\site-packages\yaml\representer.py”,行
263,在 SafeRepresenter.add_representer(datetime.date, AttributeError: module 'datetime' has no attribute 'date'
如何让import yaml 工作?
【问题讨论】:
-
您是否在错误消息中显示的任何目录中碰巧有一个
datetime.py文件?如果你这样做,那么重命名它 -
哇,我永远也抓不到那个!如果你能解释你的思维过程,我会很高兴
-
我通过答案添加了更多
标签: python python-3.x pyyaml