Bottom Page

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'
Quote
#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.
Quote
#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'
Quote
#4
Sorry, I don't have any glue what happens on your pc.
Quote
#5
I solved it! I had to install numpy properly. https://solarianprogrammer.com/2017/02/2...3-windows/
Quote
#6
Glad to hear.
Quote
#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
Quote
#8
Super, you solved it yourself.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Error installing numpy srm 3 179 Jul-08-2019, 06:26 PM
Last Post: srm
  Array in numpy Truman 5 3,247 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 153 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 192 May-23-2019, 04:15 PM
Last Post: michalmonday
  Pandas to_csv in for loop AttributeError: 'tuple' object has no attribute 'to_csv' NSearch 9 948 Apr-22-2019, 05:05 PM
Last Post: Yoriz
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 241 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  while creating a array using numpy.arrange, how to negate only the last 50 numbers? vicky53 1 244 Apr-06-2019, 11:52 AM
Last Post: scidam
  counting the occurence of a specified number in a numpy-matrix PhysChem 1 219 Apr-03-2019, 01:37 PM
Last Post: PhysChem
  How to get the size of a numpy array? mcgrim 2 296 Mar-23-2019, 02:25 PM
Last Post: perfringo
  AttributeError: 'NoneType' object has no attribute 'all' synthex 2 474 Mar-07-2019, 11:11 AM
Last Post: synthex

Forum Jump:


Users browsing this thread: 1 Guest(s)