python - numpy does not work through terminal -


di have installe numpy on ubuntu executing

sudo apt-get install python-numpy 

while executing on terminal error.

>>> import numpy np traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named numpy >>>  

why happening? tried many times going through internet couldnt find solution.could please tell me how solve this?

edit1: came know have install numpy python version run on terminal, using pip.. python 2.7.3 runs when enter 'python' on terminal. means have install numpy python 2.7.3. can guide me how it? couldnt figure out myself. btw using ubuntu 12.04 if helps.

edit 2: did more digging this.. /usr/lib contains 2 directories python2.7 , python3.while python2.7 directory consists of large number of files , sub directories,python3 directory has dist-packages subdirectory consists of deb_conf.py anf lsb_release.py..i think tried python3 few months , removed it..but right python2.7 thing having.

edit 3:

so here outputs of commands asked me enter

~$ virtualenv --no-site-package -p /usr/bin/python2.7 my_env running virtualenv interpreter /usr/bin/python2.7 --no-site-packages flag deprecated; default behavior. new python executable in my_env/bin/python2.7 not overwriting existing python script my_env/bin/python (you must use my_env/bin/python2.7) installing  distribute..............................................................................................................................................................................................done. ~$ source my_env/bin/activate ~$ pip install numpy 

last command gave generated lot of logs ended this..

creating build/scripts.linux-i686-2.7/f2py2.7   adding 'build/scripts.linux-i686-2.7/f2py2.7' scripts changing mode of build/scripts.linux-i686-2.7/f2py2.7 664 775  changing mode of /home/sandeep/my_env/bin/f2py2.7 775 installed numpy cleaning up... 

after these tried run python again , output.

~$ python python 2.7.3 (default, jan 20 2013, 21:40:19)  [gcc 4.6.3] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import numpy np traceback (most recent call last):   file "<stdin>", line 1, in <module> importerror: no module named numpy >>>  

in case nothing works.

  1. install python-virtualenv if it's not yet done.
  2. create virtual env

    virtualenv name

  3. start virtualenv

    source name/bin/activate

  4. install numpy easy_install or pip

  5. profit

note:

virtualenv activation has done everytime. can make task easier virtualenv wrapper.

http://virtualenvwrapper.readthedocs.org/en/latest/

there lot of reasons use virtualenv instead of ubuntu packages. in way, recommend not touching as possible "os" python. , if need project, use virtualenv. python in virtualenv won't mess other apps , don't have use sudo install new packages.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -