powershellnumpypippython-3.6

ImportError: cannot import name 'Template'


import numpy as np
from statistics import mean
x=[1,2,3,4,5]
y=[6,7,8,9,10]
m=((mean(x)*mean(y)-mean(x*y))/(mean(x)**2)-(mean(x**2)))
print(m)

In the above the(or any other code where I run numpy), Firstly I am getting an input request when running the program. Something like this:

PS D:\Codes\Python> python practice.py
Enter no.: 1
Enter: 1

which should not happen as values are initialized. I saw in other forums regarding how the file should not be named after a Python module(which you can see, it isn't). Even after that I'm getting error:

"C:\Users\KIIT\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 28, in <module>
    from string import Template
ImportError: cannot import name 'Template'

Can someone please tell me what to do about it? Edit: This problem is only powershell centric. The problem is faced when I run program through powershell. It works fine in IDLE.


Solution

  • There must be a file named "string.py" in your D:\Codes\Python.

    You can rename it to solve this issue. You should not name the file to the modules in Python Standard Library.