No module named error

129 views
Skip to first unread message

patito feo

unread,
Jun 13, 2020, 7:35:44 PM6/13/20
to web...@googlegroups.com
Hi,

Im trying to use a module file inside /modules/ folder but keep getting this error.

2.19.1-stable+timestamp.2020.03.21.21.49.28
(Running on nginx/\1.10.3, Python 2.7.13)

failed to reload module because:
ImportError('No module named mdplenus.modules.test',)

António Ramos

unread,
Jun 13, 2020, 7:45:39 PM6/13/20
to web...@googlegroups.com
if all is ok, restart web2py

Em dom., 14 de jun. de 2020 às 00:35, patito feo <xgp.l...@gmail.com> escreveu:
Hi,

Im trying to use a module file inside /modules/ folder but keep getting this error.


failed to reload module because:
ImportError('No module named mdplenus.modules.test',)

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/ba92fb90-96da-48a1-8130-b12a0256bb84o%40googlegroups.com.

patito feo

unread,
Jun 20, 2020, 4:14:58 PM6/20/20
to web2py-users
Hi,

Please define "all ok"

__init__.py file in /modules
.py file in /modules


Thnx for your help!




El sábado, 13 de junio de 2020, 18:45:39 (UTC-5), Ramos escribió:
if all is ok, restart web2py

Em dom., 14 de jun. de 2020 às 00:35, patito feo <xgp....@gmail.com> escreveu:
Hi,

Im trying to use a module file inside /modules/ folder but keep getting this error.


failed to reload module because:
ImportError('No module named mdplenus.modules.test',)

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web...@googlegroups.com.

António Ramos

unread,
Jun 21, 2020, 12:46:39 PM6/21/20
to web...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/64e635de-af0b-4184-8ae5-d887eb52e346o%40googlegroups.com.

patito feo

unread,
Jun 22, 2020, 8:13:46 AM6/22/20
to web2py-users
Hi,

I have done every recommended guide iv seen. Same error.

Every time i saved the .py module file same message shows on top of the editor.



Thanks in advance,

Dave S

unread,
Jun 22, 2020, 3:33:28 PM6/22/20
to web2py-users


On Monday, June 22, 2020 at 5:13:46 AM UTC-7, patito feo wrote:
Hi,

I have done every recommended guide iv seen. Same error.

Every time i saved the .py module file same message shows on top of the editor.

 
That's the editor/IDE shipped with web2py?  (When you save a file, it tries to load the file to check for syntax errors)

Below you refer to "/modules".  Please clarify if you mean "./modules" relative to the application directory, or some other location.

In the IDE, a file in "./modules" would show up under "Modules" in the files sidebar.

/dps

patito feo

unread,
Jul 17, 2020, 6:21:27 PM7/17/20
to web2py-users
Hi,


__init__.py file in ./modules
moduloname.py file in ./modules

But the module still not loade. An error is pop in the web-ide.



Thanks,


Dave S

unread,
Jul 18, 2020, 4:20:28 PM7/18/20
to web2py-users


On Friday, July 17, 2020 at 3:21:27 PM UTC-7, patito feo wrote:
Hi,


__init__.py file in ./modules
moduloname.py file in ./modules

But the module still not loade. An error is pop in the web-ide.

[...]
failed to reload module because:
ImportError('No module named mdplenus.modules.test',

Is "mdplenus.py" in ./modules?  The name has to match.  Is "test" the name of your application?

/dps
 
 

xgp.l...@gmail.com

unread,
Jul 18, 2020, 5:15:13 PM7/18/20
to web2py-users
Hi,

Im replicating the example from the book for better testing:

./modules/mytest.py

from gluon import current

def ip():
  return current.request.client

./controllers/test.py

from applications.mdplenus.modules.mytest import ip

def index():
    return "Your ip is " + mytest.ip()


* Same error: ImportError('No module named apptest.modules.mytest',)


______________________
Thanks in advance,

Dave S

unread,
Jul 22, 2020, 2:28:29 AM7/22/20
to web2py-users


On Saturday, July 18, 2020 at 2:15:13 PM UTC-7, xgp.l...@gmail.com wrote:
Hi,

Im replicating the example from the book for better testing:

./modules/mytest.py

from gluon import current

def ip():
  return current.request.client

./controllers/test.py

from applications.mdplenus.modules.mytest import ip

I have a function restuff() in  dot/modules/restuff.py

I use "import restuff"

I admit that for those files  I'm on python 2.7.something and several bumps back  on web2py versions (I've tried newer ones, just haven't needed to go all in for them yet).  So it's possible that something changed that broke things, but I expect the regression tests Massimo has would have caught it.

web2py, unlike the newer py4web, uses a custom importer.


def index():
    return "Your ip is " + mytest.ip()


* Same error: ImportError('No module named apptest.modules.mytest',)


/dps
 

AGRogers

unread,
Jul 22, 2020, 2:41:43 AM7/22/20
to web...@googlegroups.com
I think I'm on the latest versions of web2py and python. And i have problems getting modules to recompile (not sure how related that is to this topic). I gave up and just put all my modules in the Models folder. That always works for me. I'm going to need to sort that out though at some point.  But to be clear, i am not saying there is anything wrong with web2py. My general knowledge is scant so it could well be me doing something wrong.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/c1e19587-9ad9-40d0-9718-fb7200da3f64o%40googlegroups.com.

xgp.l...@gmail.com

unread,
Jul 22, 2020, 8:58:18 PM7/22/20
to web2py-users
Hi,

Im using :
2.19.1-stable+timestamp.2020.03.21.21.49.28

Maybe importing modules is broken?


Cheers,

Dave S

unread,
Jul 22, 2020, 9:35:25 PM7/22/20
to web2py-users


On Tuesday, July 21, 2020 at 11:41:43 PM UTC-7, AGRogers wrote:
I think I'm on the latest versions of web2py and python. And i have problems getting modules to recompile (not sure how related that is to this topic). I gave up and just put all my modules in the Models folder. That always works for me. I'm going to need to sort that out though at some point.  But to be clear, i am not saying there is anything wrong with web2py. My general knowledge is scant so it could well be me doing something wrong.


There's a performance impact of putting more files in the Models folder.

/dps
 
To unsubscribe from this group and stop receiving emails from it, send an email to web...@googlegroups.com.

Dmitrii Ermolaev

unread,
Sep 6, 2020, 3:19:14 PM9/6/20
to web2py-users
need __init__.py in main folder of application too!

четверг, 23 июля 2020 г. в 04:35:25 UTC+3, snide...@gmail.com:

xgp.l...@gmail.com

unread,
Sep 6, 2020, 11:07:44 PM9/6/20
to web2py-users
Its correct. Module its now working. Thanks sr.
Reply all
Reply to author
Forward
0 new messages