Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import numpy with python 2.6

This may be a simple question, but I am stuck: I want to use numpy with Python 2.6. I appended the path where the numpy folder is located:

C:\Python26\lib\site-packages\

and also the path for the numpy folder itself

C:\Python26\lib\site-packages\numpy

However, this error message appears

x=np.array([[7,8,5][3,5,7]],np.int32)


   Traceback (most recent call last):
      File "<pyshell#12>", line 1, in <module>
        x=np.array([[7,8,5][3,5,7]],np.int32)
    NameError: name 'np' is not defined

Could you help me with this?

like image 939
kiriloff Avatar asked Jan 13 '12 14:01

kiriloff


People also ask

Does Python 2 have NumPy?

The NumPy project has supported both Python 2 and Python 3 in parallel since 2010, and has found that supporting Python 2 is an increasing burden on our limited resources; thus, we plan to eventually drop Python 2 support as well.

Why is NumPy not importing?

Python import numpy is not working that means eithers the module is not installed or the module is corrupted. To fix the corrupted module, uninstall it first then reinstall it.


1 Answers

You shouldn't have to add those things to the path. Python knows where to look for installed modules as long as you have C:\Python26 in the path.

Sven Marnach was asking if you did it like this:

import numpy as np
x=np.array([[7,8,5],[3,5,7]],np.int32)

Edit: I just noticed you left out a comma in your array declaration also...fixed it in the above

like image 73
Matt Avatar answered Oct 04 '22 02:10

Matt