I can't get the module numpy to work in python

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
jump
Posts: 10
Joined: Mon 08 Feb 2010, 23:22

I can't get the module numpy to work in python

#1 Post by jump »

I wanted to do matrix operations on image data using PIL (python image libery) and numpy for mathematical matrix/array style operations.

my comuter says...
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
which is annoying because i have tried a number of different pet packages, even the one i found in the repository and python doesn't see it. I am using Lupu 5.1.1. (Actual i think the modual is playing with me because i first thought it was called numpty!).

if you can help me with this i will be thankful cos i think numpy will make the image processing algorithms neater, quicker and easier to write...
Last edited by jump on Fri 17 Sep 2010, 12:03, edited 1 time in total.

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#2 Post by neurino »

If the problem is you install numpy module (have tried with easy_install?) but you can't >>> import numpy the check a link to numpy package is present in your your *pythonlib*/site-packages/easy-install.pth

it's a common problem with PIL too after installing with easy_install you have to add it by hand.

Greetings

User avatar
jump
Posts: 10
Joined: Mon 08 Feb 2010, 23:22

#3 Post by jump »

thanks neurino.
i didn't know that easy_install existed and i had tryed to install using only the puppy package manager (it seems there is much to learn...mmm).
So i have just been to the site
http://pypi.python.org/pypi/setuptools#downloads
and downloaded the .egg file in order to get easy_install.
when i ran the file as described i got the error
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 2] No such file or directory: '/usr/local/lib/python2.6/dist-packages/test-easy-install-27695.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.6/dist-packages/

This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).

#
which made me think "well where did it put the PIL module files, which worked"... i found the PIL files in this directory /usr/lib/python2.6/dist-packages/ !!!

interestingly i found the numpy files in /usr/lib/python2.6/site-packages/ !!

so i think i will try using the .egg file for easy_install given the directory /usr/lib/python2.6/dist-packages/ then if that works try to install numpy the right way!!! Thanks again... stop me if I'm going to make a further mess though!

User avatar
jump
Posts: 10
Joined: Mon 08 Feb 2010, 23:22

#4 Post by jump »

i think i have made a great big pile of mess....

i installed easy_install in the directory /usr/lib/python2.6/dist-packages/ using the .egg file. That seemed to work.
When i went to the folder and ran the script easy_install it asked for the /usr/local/lib/python2.6/dist-packages/ folder again and if i didn't have it told me to make it.... so i started again, i made the folder /usr/local/lib/python2.6/dist-packages/ and reinstalled easy_install there using the .egg file.

then i ran
# easy_install NumPy
and got this...
# easy_install NumPy
Searching for NumPy
Reading http://pypi.python.org/simple/NumPy/
Reading http://numpy.scipy.org
Reading http://sourceforge.net/project/showfile ... _id=175103
Reading http://numeric.scipy.org
Best match: numpy 1.5.0
Downloading http://sourceforge.net/projects/numpy/f ... p/download
Processing download
Running numpy-1.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1GDYA6/numpy-1.5.0/egg-dist-tmp-xw0FW4
Running from numpy source directory.non-existing path in 'numpy/distutils': 'site.cfg'
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1399: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1408: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
warnings.warn(BlasNotFoundError.__doc__)
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1411: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
warnings.warn(BlasSrcNotFoundError.__doc__)
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1306: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1317: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
warnings.warn(LapackNotFoundError.__doc__)
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/system_info.py:1320: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
warnings.warn(LapackSrcNotFoundError.__doc__)
Could not locate executable g77
Could not locate executable f77
Could not locate executable ifort
Could not locate executable ifc
Could not locate executable lf95
Could not locate executable pgf90
Could not locate executable pgf77
Could not locate executable f90
Could not locate executable f95
Could not locate executable fort
Could not locate executable efort
Could not locate executable efc
Could not locate executable gfortran
Could not locate executable g95
don't know how to compile Fortran code on platform 'posix'
don't know how to compile Fortran code on platform 'posix'
don't know how to compile Fortran code on platform 'posix'
_configtest.c:1: warning: conflicting types for built-in function 'exp'
_configtest.o: In function `main':
/tmp/easy_install-1GDYA6/numpy-1.5.0/_configtest.c:6: undefined reference to `exp'
collect2: ld returned 1 exit status
_configtest.o: In function `main':
/tmp/easy_install-1GDYA6/numpy-1.5.0/_configtest.c:6: undefined reference to `exp'
collect2: ld returned 1 exit status
don't know how to compile Fortran code on platform 'posix'
don't know how to compile Fortran code on platform 'posix'
_configtest.c:1: warning: conflicting types for built-in function 'exp'
don't know how to compile Fortran code on platform 'posix'
don't know how to compile Fortran code on platform 'posix'
_configtest.c:1:20: error: Python.h: No such file or directory
_configtest.c:1:20: error: Python.h: No such file or directory
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 8, in <module>
load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 1712, in main
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 1700, in with_ei_usage
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 1716, in <lambda>
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 211, in run
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 446, in easy_install
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 476, in install_item
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 655, in install_eggs
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 930, in build_and_install
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/easy_install.py", line 919, in run_setup
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/sandbox.py", line 62, in run_setup
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/sandbox.py", line 105, in run
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/sandbox.py", line 64, in <lambda>
File "setup.py", line 211, in <module>
File "setup.py", line 204, in setup_package
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/core.py", line 186, in setup
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/usr/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg/setuptools/command/bdist_egg.py", line 167, in run
File "/usr/lib/python2.6/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/command/egg_info.py", line 8, in run
File "/usr/lib/python2.6/distutils/cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/command/build_src.py", line 152, in run
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/command/build_src.py", line 169, in build_sources
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/command/build_src.py", line 328, in build_extension_sources
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/command/build_src.py", line 385, in generate_sources
File "numpy/core/setup.py", line 399, in generate_config_h
File "numpy/core/setup.py", line 41, in check_types
File "numpy/core/setup.py", line 260, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/misc_util.py:251: RuntimeWarning: Parent module 'numpy.distutils' not found while handling absolute import
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/misc_util.py", line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/tmp/easy_install-1GDYA6/numpy-1.5.0/numpy/distutils/misc_util.py", line 251, in clean_up_temporary_directory
ImportError: No module named numpy.distutils
#
ooops! i've not a clue!

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#5 Post by neurino »

I hardly understand what did you do :lol: so allow me to make you a little to-do list to see if you can get it to work

- which version of pyton are you running? I assume 2.6

- go to http://pypi.python.org/pypi/setuptools and download 2.6 python egg and save it wherever you like (/tmp :idea: ) or copy the link and wget it

Code: Select all

#cd /tmp
  #wget http://pypi.python.org/packages/2.6/s/setuptools/....
- add execute permission to the file if needed

Code: Select all

#chmod a+x setuptools-0.6...
- execute it as shell script

Code: Select all

#./setuptools-0.6...
it will install where it has to.

- try installing numpy from pypi (please note use always lowercase package names)

Code: Select all

#easy_install numpy
if recall correctly you should not have problems but you may require devx sfs loaded if numpy setup.py needs to compile something during installation (not later).

Then test it

Code: Select all

#python2.6
>>>import numpy
I hope you did not corrupted something in your first attempts.

There are some packages that need to be compiled stand alone (wxpython) others that rely on libraries you can have troubles compiling (scipy) but numpy should install easily.

should...

User avatar
jump
Posts: 10
Joined: Mon 08 Feb 2010, 23:22

#6 Post by jump »

before i started changing things i made a backup copy of my lupu puppy savefile... i have just replaced my current save file with that one so i can start again!!! :lol:

I am running python2.6 from the lupu_devx_511.sfs which i have installed.

I have followed your steps :lol: and the python egg says i am missing the directory

/usr/local/lib/python2.6/dist-packages/

and that if i do not have this directory i should make it and try again. I did this and it seemed to install.
When i used the following command...

# easy_install numpy

...everything downloaded ok but there were many problems installing...

the error messages started like this...

Running from numpy source directory.non-existing path in 'numpy/distutils': 'site.cfg'
/tmp/easy_install-A1Ul1T/numpy-1.5.0/numpy/distutils/system_info.py:1399: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
warnings.warn(AtlasNotFoundError.__doc__)

.... and went on for a while. (it could not compile the fortran code either).

i think there must be some problems with some environment variables. :oops: :(

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#7 Post by neurino »

Well, it says you miss /usr/local/lib/python2.6/dist-packages/ 'cause probably you have it installed in /usr/lib not usr/local/lib like I do

you should get this answer from your python interpreter:

Code: Select all

#python2.6
>>> import copy
>>> copy.__file__
'/usr/lib/python2.6/copy.pyc'
>>>
you can tell easy_install the --install-dir but I guess there's something wrong with your python installation because I never had easy_install trying to install in the wrong directory

User avatar
jump
Posts: 10
Joined: Mon 08 Feb 2010, 23:22

#8 Post by jump »

Thanks neurino :D

i put in the code

Code: Select all

>>> import copy
>>> copy.__file__ 
and got the same results as you did..

Code: Select all

'/usr/lib/python2.6/copy.pyc'
so i am going to download the file lupu_devx_511.sfs file again
from http://www.diddywahdiddy.net/LupuNews/ and see if that helps!!

Post Reply