这个错误代码告诉我什么?即我需要解决什么

时间:2019-10-25 18:26:39

标签: python pandas numpy

此错误代码是什么意思? (有关错误代码,请参见第一个答案)尝试打开csv文件并读取数据的前5行时遇到了这个问题。

C:\Users\torou>python cleandep/py
python: can't open file 'cleandep/py': [Errno 2] No such file or directory

C:\Users\torou>python http://cleandep.py    
Traceback (most recent call last):    
File "bit_generator.pyx", line 40, in numpy.random.bit_generator    
File "C:\Users\torou\AppData\Local\Programs\Python\Python37-2\lib\http://secrets.py", line 20, in <module>    
from random import SystemRandom    
File "C:\Users\torou\http://random.py", line 1, in <module>    
from random import random    
ImportError: cannot import name 'random' from 'random' C:\Users\torou\http://random.py)    
During handling of the above exception, another exception occurred:    
Traceback (most recent call last):    
File "http://cleandep.py", line 8, in <module>    
import numpy as npy    
File "C:\Users\torou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\__init__.py", line 150, in <module>    
from . import random    
File "C:\Users\torou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\random\__init__.py", line 181, in <module>    
from . import _pickle    
File "C:\Users\torou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\numpy\random\_pickle.py", line 1, in <module>    
from .mtrand import RandomState    
File "mtrand.pyx", line 9, in init numpy.random.mtrand
File "mt19937.pyx", line 1, in init numpy.random.mt19937    
File "bit_generator.pyx", line 43, in init numpy.random.bit_generator    
File "C:\Users\torou\http://random.py", line 1, in <module>    
from random import random    
ImportError: cannot import name 'random' from 'random' C:\Users\torou\http://random.py)    

这是我尝试运行的python 3代码:

import numpy as npy
import pandas as pd
data= pd.read_csv("cti-april02-log")
data.head()

1 个答案:

答案 0 :(得分:2)

您有一个名为random.py的文件,该文件会覆盖标准库中具有相同名称的模块(即,它尝试从文件random.py中而不是标准库中的模块中随机导入