Using NumPy for python version 3.6, just installed it via pip
. For simple scripts I keep getting an odd error that I can't understand
Example script:
#!/usr/bin/python3
import numpy as np
a = np.zeros((2,2))
print(a)
Output being when run:
Traceback (most recent call last): File "", line 1, in File "/Users/Zhiang/Projects/LearningPython/Test.py", line 4, in a = np.zeros((2,2)) # Create an array of all zeros AttributeError: module 'numpy' has no attribute 'zeros'
I am still new to using python and have no idea what to do. I have tried reinstalling NumPy.Even going as far as reinstalling pip
for python 3.6. Anyone know what to do ?
See comments - Issue solved by deleting the pyc files.
Python checks to see if the .pyc file's internal timestamp matches the corresponding .py file, and if it does, it loads the .pyc. This can be an issue if you update and you're still using the previously compiled .pyc.
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.