[英]Anaconda: Attribute error while running pylab with anaconda distribution on Windows
I am trying to import pylab and this is the code that I am writing. 我正在尝试导入pylab,这是我正在编写的代码。
import pylab
pylab.figure(1)
pylab.plot([1,2,3,4],[1,7,3,5])
pylab.show()
But I am getting the error that 但是我得到的错误是
File "E:\mitedx1\mitedx2\week1\pylab.py", line 2, in <module>
import pylab
File "E:\mitedx1\mitedx2\week1\pylab.py", line 4, in <module>
pylab.figure(1)
AttributeError: 'module' object has no attribute 'figure'
[Finished in 0.1s with exit code 1]
I tried to take help from the answers provided here 我试图从此处提供的答案中寻求帮助
Anaconda: Unable to import pylab Anaconda:无法导入pylab
but to no rescue. 但无济于事。 I have also checked the path with cmd, and it is showing the inclusion of C:\\Anaconda and C:\\Anaconda\\Scripts there.
我还使用cmd检查了路径,并且显示了其中包含C:\\ Anaconda和C:\\ Anaconda \\ Scripts的路径。 What would be the solution to fix this problem?
解决该问题的解决方案是什么?
You called your script pylab.py
, rename it to something else. 您将脚本命名为
pylab.py
,将其重命名为其他名称。
E:\mitedx1\mitedx2\week1\pylab.py # <- you are importing from this not the pylab module
Make sure to delete the E:\\mitedx1\\mitedx2\\week1\\pylab.pyc
file also. 确保还删除
E:\\mitedx1\\mitedx2\\week1\\pylab.pyc
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.