Python Forum
AttributeError: module 'numpy' has no attribute 'array - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: AttributeError: module 'numpy' has no attribute 'array (/thread-18655.html)



AttributeError: module 'numpy' has no attribute 'array - aapurdel - May-26-2019

>>> import numpy as np
>>> np.__file__
'C:\\Adrian\\Python37\\Lib\\numpy-1.11.2\\numpy\\__init__.py'
>>> list_int = [8, 3, 34, 111]
>>> a_int = np.array(list_int)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
a_int = np.array(list_int)
AttributeError: module 'numpy' has no attribute 'array'


RE: AttributeError: module 'numpy' has no attribute 'array - heiner55 - May-26-2019

Do yo have a file called numpy.py in your working directory?
If yes, rename it.

For your task in https://python-forum.io/Thread-Question-1-Count-symbols
you do not need numpy.


RE: AttributeError: module 'numpy' has no attribute 'array - aapurdel - May-26-2019

I do not have a file named numpy.py.
My exact steps are: in Python, Open C:\Adrian\Python37\Lib\numpy-1.11.2\setup.py, I run this module:
>>>
=========== RESTART: C:\Adrian\Python37\Lib\numpy-1.11.2\setup.py ===========
Running from numpy source directory.
>>> import numpy as np
>>> list_int = [8, 3, 34, 111]
>>> a_int = np.array(list_int)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
a_int = np.array(list_int)
AttributeError: module 'numpy' has no attribute 'array'


RE: AttributeError: module 'numpy' has no attribute 'array - heiner55 - May-26-2019

Sorry, I don't have any glue what happens on your pc.


RE: AttributeError: module 'numpy' has no attribute 'array - aapurdel - May-26-2019

I solved it! I had to install numpy properly. https://solarianprogrammer.com/2017/02/25/install-numpy-scipy-matplotlib-python-3-windows/


RE: AttributeError: module 'numpy' has no attribute 'array - heiner55 - May-26-2019

Glad to hear.


RE: AttributeError: module 'numpy' has no attribute 'array - snippsat - May-26-2019

(May-26-2019, 10:54 AM)aapurdel Wrote: I solved it! I had to install numpy properly. https://solarianprogrammer.com/2017/02/2...3-windows/
The tutorial is ok,but there is is one redirection that is not needed.
python -m pip install numpy
# Only this is needed
pip install numpy
pip should work from anywhere in cmd/cmder.
# Check pip
C:\
λ pip -V
pip 19.1.1 from c:\python37\lib\site-packages\pip (python 3.7)

# Install
C:\
λ pip install numpy
Collecting numpy
  Downloading ... numpy-1.16.3-cp37-cp37m-win32.whl (10.0MB)
     |████████████████████████████████| 10.0MB 297kB/s
Installing collected packages: numpy
Successfully installed numpy-1.16.3

# Test that it work
C:\
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
>>> numpy.__version__
'1.16.3'
>>> exit()
Python 3.6/3.7 and pip installation under Windows


RE: AttributeError: module 'numpy' has no attribute 'array - heiner55 - May-29-2019

Super, you solved it yourself.