Python matplotlib

hi all
the following code

import matplotlib.pyplot as plt 
import numpy as np

def f(x):
	return x**2
x= np.linspace(0,10,1000)	
plt.plot(x,f(x))
plt.show()

runs normally when i run commands 1 by 1 but when i have it in a file i get error
report

================= RESTART: C:\Python34\training\matplot1.py =================
1267650600228229401496703205376
Traceback (most recent call last):
  File "C:\Python34\training\matplot1.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python34\lib\site-packages\matplotlib\__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "C:\Python34\lib\site-packages\matplotlib\cbook.py", line 33, in <module>
    import numpy as np
  File "C:\Python34\lib\site-packages\numpy\__init__.py", line 180, in <module>
    from . import add_newdocs
  File "C:\Python34\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Python34\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Python34\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Python34\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
    from . import _internal  # for freeze programs
  File "C:\Python34\lib\site-packages\numpy\core\_internal.py", line 15, in <module>
    from .numerictypes import object_
  File "C:\Python34\lib\site-packages\numpy\core\numerictypes.py", line 962, in <module>
    _register_types()
  File "C:\Python34\lib\site-packages\numpy\core\numerictypes.py", line 958, in _register_types
    numbers.Integral.register(integer)
AttributeError: 'module' object has no attribute 'Integral'
>>> 

any idea what is happen

1 Like

Perhaps @sdaityari or @abderhasan could help with that. They are pretty good with Python. :slight_smile:

I’m not a python expert, but this looks similar
https://bbs.archlinux.org/viewtopic.php?id=193965

Ok i found my fault. I had a python file in my exercise folder named numbers.py That caused the problem. It was in same folder with the matplot exercise file and the programm was reading this instead numbers.py from standard library. I renamed it and now it runs normally. Stupid from me but happened.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.