[web2py] ImportError: No module named ...

2010-01-20 Thread kari
Hi,
I am facing a problem on Windows installation of web2py. When trying
to run applications I get the following error:

ImportError: No module named ...

... replaced by a model I have used in the import statement in
default.py

All the modules I have used are installed and thety can be imported
when called from the python console or with any ordinary python
application by 'python foo.py' type of a call.

It seems web2py does not understand the paths the same way as my
python installation. Any ideas how this could be fixed?

Many thanks.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py] Re: ImportError: No module named ...

2010-01-20 Thread kari
Thanks for the reply - I think a typo in my original message might
have
given a wrong impression of the problem I am facing.

Instead of '... replaced by a model I have used in the import
statement'
it should have said '... replaced by a MODULE I have used...', for
example:

import numpy

But then when trying too run the application in web2py I get an error:
ImportError: No module named numpy

I should also add that the same applications work fine on web2py in my
Ubuntu 9.10 box.

I tried to add
numpy = local_import('numpy') to the beginning of the default.py to no
avail (if I understood your advice correctly).

kari

On Jan 20, 5:18 pm, mdipierro  wrote:
> You do not import models like you do in Django. models are
> automatically executed in alphabetic order before the controller.
>
> You only import third party modules (as long as they are properly
> installed) or modules in the /app/modules/ folder using
>
>    mymodule=local_import('mymodule')
>
> Hope this helps.
>
> Massimo
>
> On Jan 20, 5:34 am, kari  wrote:
>
> > Hi,
> > I am facing a problem on Windows installation of web2py. When trying
> > to run applications I get the following error:
>
> > ImportError: No module named ...
>
> > ... replaced by a model I have used in the import statement in
> > default.py
>
> > All the modules I have used are installed and thety can be imported
> > when called from the python console or with any ordinary python
> > application by 'python foo.py' type of a call.
>
> > It seems web2py does not understand the paths the same way as my
> > python installation. Any ideas how this could be fixed?
>
> > Many thanks.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py] Re: ImportError: No module named ...

2010-01-20 Thread kari
Thanks - I did not realise the binary vs source thing. When changing
from Windows binary to the source everything works as expected. Great!

Many thanks for you help.

On Jan 21, 8:47 am, mdipierro  wrote:
> I think I understand the problem now.
>
> If you try to "import numpy" you need to:
> 1) make sure numpy is installed
> 2) make sure you run web2py from source (not the binary) since the
> binary comes with its own Python and it does not see modules installed
> with the "other" Python.
> 3) make sure you start web2py.py with the same Python version you used
> to install numpy.
>
> Hope this helps.
>
> On Jan 20, 11:45 pm, kari  wrote:
>
> > Thanks for the reply - I think a typo in my original message might
> > have
> > given a wrong impression of the problem I am facing.
>
> > Instead of '... replaced by a model I have used in the import
> > statement'
> > it should have said '... replaced by a MODULE I have used...', for
> > example:
>
> > import numpy
>
> > But then when trying too run the application in web2py I get an error:
> > ImportError: No module named numpy
>
> > I should also add that the same applications work fine on web2py in my
> > Ubuntu 9.10 box.
>
> > I tried to add
> > numpy = local_import('numpy') to the beginning of the default.py to no
> > avail (if I understood your advice correctly).
>
> > kari
>
> > On Jan 20, 5:18 pm, mdipierro  wrote:
>
> > > You do not import models like you do in Django. models are
> > > automatically executed in alphabetic order before the controller.
>
> > > You only import third party modules (as long as they are properly
> > > installed) or modules in the /app/modules/ folder using
>
> > >    mymodule=local_import('mymodule')
>
> > > Hope this helps.
>
> > > Massimo
>
> > > On Jan 20, 5:34 am, kari  wrote:
>
> > > > Hi,
> > > > I am facing a problem on Windows installation of web2py. When trying
> > > > to run applications I get the following error:
>
> > > > ImportError: No module named ...
>
> > > > ... replaced by a model I have used in the import statement in
> > > > default.py
>
> > > > All the modules I have used are installed and thety can be imported
> > > > when called from the python console or with any ordinary python
> > > > application by 'python foo.py' type of a call.
>
> > > > It seems web2py does not understand the paths the same way as my
> > > > python installation. Any ideas how this could be fixed?
>
> > > > Many thanks.
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.




[web2py] read a blob to numpy array

2010-02-03 Thread kari
I need to read a csv file consisting of one row, split its contents to
values and then do some calculations with these values and store
results of these calculations in a database that already has some
fields filled and a record id. I would like the users to be offered a
file open dialog for choosing the file. I am thinking of saving the
csv file to a blob field with (Field('csvfile','upload') but I am
uncertain how can I read the contents of the blob and convert it to a
numpy array for calculations.

Can the blob be treated as a file stream?

In addition, my simple attempts to try to retrieve the contents of the
blob (opening the file saved) appear to result in an error that the
file is not found when I try to reference it by the 'csvfile' name
saved. Appadmin shows a 'file' link that offers to download the file -
but I have not been able to solve how this works.

Any suggestions? Or alternative solutions to solve the problem?

Many thanks, Kari

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: read a blob to numpy array

2010-02-03 Thread kari
I apparently solved this. I needed to add "uploads/" between the
request.folder and the filename I got from the blob object when
concatenating the path since the files are stored in the "uploads"
folder. I missed this in my first attempts.

Kari

On Feb 3, 10:51 am, kari  wrote:
> I need to read a csv file consisting of one row, split its contents to
> values and then do some calculations with these values and store
> results of these calculations in a database that already has some
> fields filled and a record id. I would like the users to be offered a
> file open dialog for choosing the file. I am thinking of saving the
> csv file to a blob field with (Field('csvfile','upload') but I am
> uncertain how can I read the contents of the blob and convert it to a
> numpy array for calculations.
>
> Can the blob be treated as a file stream?
>
> In addition, my simple attempts to try to retrieve the contents of the
> blob (opening the file saved) appear to result in an error that the
> file is not found when I try to reference it by the 'csvfile' name
> saved. Appadmin shows a 'file' link that offers to download the file -
> but I have not been able to solve how this works.
>
> Any suggestions? Or alternative solutions to solve the problem?
>
> Many thanks, Kari

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.