Install Python Module in local install of web2py
Asked Answered
C

3

8

I am running web2py on a Windows machine.

I'm working on an application, but it keeps erroring because it says the module I'm trying to use isn't installed. It is however installed in my local python install.

How can I install modules so that web2py can recognize them?

Cantlon answered 15/11, 2011 at 3:52 Comment(0)
D
13

web2py recognize any module you have in your local Python installation, unless you have a module with the same name under /modules folder of your application.

If you are on windows I do not recommend the use of .exe version of web2py (this version is only for studies) and it has a self contained isolated Python interpreter.

Make sure you are using source version of web2py and Python 2.5+ on your windows.

web2py should import any module from your Python path, also you can drop modules in app/modules folder ], then web2py will check there first when import something.

Danonorwegian answered 15/11, 2011 at 5:44 Comment(0)
J
5

If you are using the Windows binary version (i.e., web2py.exe), note that it includes its own Python interpreter, which means it will not use your installed version of Python and will therefore not see any of your installed modules. You can put Python modules in the /web2py/site-packages folder (which is created the first time you run the binary version), but the better approach is probably just to run the source code version of web2py. It's just as easy -- simply download and unzip the source code package, and instead of clicking on web2py.exe, you click on web2py.py (or at a command prompt, cd to the web2py directory and enter python web2py.py).

Justiciary answered 15/11, 2011 at 12:55 Comment(0)
S
0

What about add your local module path into sys.path variable?

sys.path.apend('/path/to/your/module/directory')

By the way, which module is not found by web2py

Stetson answered 15/11, 2011 at 4:28 Comment(1)
This is not thread safe, unless you do in the handler. better to simply install the modules in the web2py (or the python) site-packagesAnisomerous

© 2022 - 2024 — McMap. All rights reserved.