在 web2py 的本地安装中安装 Python 模块
我在 Windows 机器上运行 web2py。
我正在开发一个应用程序,但它不断出错,因为它说我尝试使用的模块未安装。然而它安装在我的本地 python 安装中。
如何安装模块以便 web2py 可以识别它们?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
web2py 可以识别本地 Python 安装中的任何模块,除非应用程序的 /modules 文件夹下有同名的模块。
如果您使用的是 Windows,我不建议使用 .exe 版本的 web2py(该版本仅用于研究),它有一个独立的独立 Python 解释器。
确保您在 Windows 上使用 web2py 源版本 和 Python 2.5+。
web2py 应该从你的 Python 路径导入任何模块,你也可以将模块放在 app/modules 文件夹中],然后 web2py 在导入某些东西时会首先检查那里。
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.
如果您使用的是 Windows 二进制版本(即 web2py.exe),请注意它包含自己的 Python 解释器,这意味着它不会使用您安装的 Python 版本,因此不会看到您安装的任何模块。您可以将 Python 模块放在 /web2py/site-packages 文件夹中(该文件夹是您第一次运行二进制版本时创建的),但更好的方法可能只是运行 web2py 的源代码版本。它同样简单 - 只需下载并解压缩源代码包,然后单击 web2py.py(或在命令提示符下,
cd
到 web2py 目录,然后单击 web2py.exe,然后单击输入python web2py.py
)。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 enterpython web2py.py
).将本地模块路径添加到 sys.path 变量中怎么样?
sys.path.apend('/path/to/your/module/directory')
顺便说一句,web2py没有找到哪个模块
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