我通常懒得安装 Python 模块。我使用 web2py,并将它们转储到模块文件夹中,让它处理本地导入。它似乎总是最直接的做事方式——从来没有觉得在系统范围内处理依赖关系是正确的,也从来没有觉得要搞乱虚拟环境。
关于 one of my other questions , 回答者说
Generally, the best practice for 3rd party modules is to install them via pip or easy_install (preferably in a virtualenv), if they're available on PyPI, rather than copying them somewhere onto your PYTHONPATH. ... [because that] runs the install scripts hooks necessary to install executable scripts, build C extensions, etc., that isn't done by just copying in a module.
这个我不是很懂。我一直认为这更像是一种偏好,但安装 3rd 方模块确实是更好的做法,我是否可能会因为不这样做而导致问题?使用像 web2py 这样的框架会有什么不同吗?
请您参考如下方法:
这取决于模块和你想用它做什么。一些软件包附带有用的命令行工具,这些工具可能只有在您正确安装它们后才能使用。
相反,如果您正在编写要分发到您没有太多控制权的环境的代码,您通常必须在您的项目中本地保留一份代码副本,因为目标环境可能没有包...当然,Web 项目通常属于此类,具体取决于您的服务环境。
