我有macOS Sierra,使用python 2.7进行作业。 我有一个导入问题如下:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/networkx/release.py", line 43, in <module>
import time
File "/Users/chen/Desktop/minesparis/JE/Chronomap/scripts/time.py", line 3, in <module>
import matplotlib.pyplot as plt
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module>
import numpy as np
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 201, in <module>
from . import random
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/random/__init__.py", line 99, in <module>
from .mtrand import *
File "mtrand.pyx", line 151, in init mtrand (numpy/random/mtrand/mtrand.c:37668)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dummy_threading.py", line 45, in <module>
import threading
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 15, in <module>
from time import time as _time, sleep as _sleep
ImportError: cannot import name time
我打开脚本threading.py并尝试运行它,一切似乎都有效。 我写的时候
from time import time as _time, sleep as _sleep
在我的控制台上,导入工作正常。 所以我不知道问题是什么,我该如何解决..
非常感谢! 米娅
答案 0 :(得分:1)
您将脚本命名为time.py
。它依赖于内置模块time
。
现在,如果您是Python解释器,您如何区分time
脚本与内置脚本之间的差异?它不能!相反,本地文件优先。
只需将脚本重命名为其他内容即可。