Python Forum
AttributeError: module 'numpy' has no attribute 'array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: module 'numpy' has no attribute 'array
#1
>>> 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'
Reply
#2
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.
Reply
#3
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'
Reply
#4
Sorry, I don't have any glue what happens on your pc.
Reply
#5
I solved it! I had to install numpy properly. https://solarianprogrammer.com/2017/02/2...3-windows/
Reply
#6
Glad to hear.
Reply
#7
(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
Reply
#8
Super, you solved it yourself.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 294 Mar-26-2024, 02:18 PM
Last Post: snippsat
  reshaping 2D numpy array paul18fr 3 970 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,530 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Numpy array BrianPA 13 4,838 Jan-23-2021, 09:36 AM
Last Post: Serafim
  How to fill datetime64 field in numpy structured array? AlekseyPython 0 2,236 Oct-20-2020, 08:17 AM
Last Post: AlekseyPython
  Adding data in 3D array from 2D numpy array asmasattar 0 2,169 Jul-23-2020, 10:55 AM
Last Post: asmasattar
  converting dataframe to int numpy array glennford49 1 2,290 Apr-04-2020, 06:15 AM
Last Post: snippsat
  Replacing sub array in Numpy array ThemePark 5 4,090 Apr-01-2020, 01:16 PM
Last Post: ThemePark
  How to prepare a NumPy array which include float type array elements subhash 0 1,884 Mar-02-2020, 06:46 AM
Last Post: subhash
  numpy.where array search for string in just one coordinate adetheheat 1 2,248 Jan-09-2020, 07:09 PM
Last Post: paul18fr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020