Problem with Import

64 views
Skip to first unread message

Quang Lam

unread,
Jun 7, 2019, 5:33:09 PM6/7/19
to web2py-users
i placed a new module file in the modules folder but i got the error saying there is no module named in the modules folder when i import the module. However, i can import the other modules in the modules folder but not the new one.
Please help 

Dave S

unread,
Jun 7, 2019, 8:16:44 PM6/7/19
to web2py-users


On Friday, June 7, 2019 at 10:33:09 AM UTC-7, Quang Lam wrote:
i placed a new module file in the modules folder but i got the error saying there is no module named in the modules folder when i import the module. However, i can import the other modules in the modules folder but not the new one.
Please help 

If you have appadmin enabled, the "sites" page has a reload button.  Otherwise, stop and restart web2py.
(I only use modules in Scheduler tasks, so it's just the -K that has to be stop-and-go)


/dps

Quang Lam

unread,
Jun 7, 2019, 8:24:23 PM6/7/19
to web2py-users
Hi Dave

i restarted the web2py, reloaded the adminpage but i still got the error saying no module named in the modules folder. i have no problem with the other modules except the new one named mode_extraction. Also, i checked my modules folder, web2py actually compiles the mode_extraction module because i saw the pyc file but i dont know why i got the error of no module named in the folder.

Thanks 

Dave S

unread,
Jun 7, 2019, 8:54:00 PM6/7/19
to web2py-users


On Friday, June 7, 2019 at 1:24:23 PM UTC-7, Quang Lam wrote:
Hi Dave

i restarted the web2py, reloaded the adminpage but i still got the error saying no module named in the modules folder. i have no problem with the other modules except the new one named mode_extraction. Also, i checked my modules folder, web2py actually compiles the mode_extraction module because i saw the pyc file but i dont know why i got the error of no module named in the folder.

Thanks 


Ah!  Maybe the custom importer is not handling the underscore.  Try renaming the module.

/dps
 

Quang Lam

unread,
Jun 10, 2019, 6:35:38 PM6/10/19
to web2py-users
Hi Dave, i named the other modules with underscore too and it worked but i dont know why this one is not working, any other suggestion?

Jonathan Clark

unread,
Jun 10, 2019, 8:53:31 PM6/10/19
to web2py-users
Hi,

If you have two modules you are importing, and one works and the other doesn't, why can't you:

1) Make them both the same content and see if you can still import both or only one. If only one works, what can the difference be except the name etc.

2) If they both import ok when they have identical content (but different names), then gradually change one of them to be the content you actually want to import, and see what it is that you change which makes the import stop working?

Good luck.

Quang Lam

unread,
Jun 10, 2019, 9:31:33 PM6/10/19
to web...@googlegroups.com
Hi Johnathan, thanks for your suggestion. it's really helpful 

it turns out that the import psycopg2 in my module caused the problem. if i take out the import psycopg2, the import module works fine. However, i need to import psycopg2 to connect postgres database. how can i fix this situation ?

Please help thanks 

Dave S

unread,
Jun 10, 2019, 9:49:24 PM6/10/19
to web2py-users


On Monday, June 10, 2019 at 2:31:33 PM UTC-7, Quang Lam wrote:
Hi Johnathan, thanks for your suggestion. it's really helpful 

it turns out that the import psycopg2 in my module caused the problem. it i take out the import psycopg2, the import module works fine. However, i need to import psycopg2 to connect postgres database. how can i fix this situation ?

Please help thanks 


Talking to pyscopg2 is normally done through the DAL.  The DAL may talk to multiple databases.

db1 = DAL(myconf.take('db1.uri'), ....)
db2
=  DAL(myconf.take('db2.uri'), ....)


/dps

Jonathan Clark

unread,
Jun 10, 2019, 9:52:05 PM6/10/19
to web...@googlegroups.com
I'm not sure I can help you. You have found the problem is to do with importing psycopg2. I have a feeling I had a similar problem and I switched to pg8000 as the driver, and it just worked. pg8000 is not supposed to be reliable though for postgresql. But it worked for me.

Good luck,
Jonathan

On Mon, 10 Jun 2019 at 22:31, Quang Lam <mrry...@csu.fullerton.edu> wrote:
Hi Johnathan, thanks for your suggestion. it's really helpful 

it turns out that the import psycopg2 in my module caused the problem. it i tool the import psycopg2, the import works fine. However, i need to import psycopg2 to connect postgres database. how can i fix this situation ?

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/7D53le8swWE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e32f82db-78b0-4b67-b005-c4e8007bb36c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages