my code is:
import random
import numpy
z = numpy.zeros(5)
print(z)
d = random.random()
and the error is:
Traceback (most recent call last):
File "/Users/wjxiz/Documents/et5/bigdata/test.py", line 6, in <module>
d = random.random()
AttributeError: 'module' object has no attribute 'random'
I hava already installed "scripts" to run scripts in atom. I installed my python3 by Homebrew and my path is:
/usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin
when I type which python3 and which python in terminal:
/usr/local/bin/python3
/usr/bin/python
I can run normal code correctly but when I import random, problem occurs.
您很可能已将文件之一命名为random.py
,因此Atom会导入该文件,而不是python random模块
创建python文件时,不要将Python文件名带有random.py或numpy.py。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.