本文介绍了我应该安装我的 Python 模块吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常不会费心安装 Python 模块.我使用 web2py,并将它们转储到模块文件夹中,让它处理本地导入.这似乎总是最直接的做事方式 - 在系统范围级别处理依赖关系从来没有感觉是正确的,也从来没有想过弄乱虚拟环境.

I generally don't bother to install Python modules. I use web2py, and just dump them in the modules folder and let it take care of the local imports. It just always seemed like the most straightforward way of doing things- never felt right about handling dependencies at a system-wide level, and never felt like messing with virtual envs.

我的其他问题之一上,回答者说

通常,第 3 方模块的最佳做法是安装它们通过 pip 或 easy_install(最好在 virtualenv 中),如果它们是在 PyPI 上可用,而不是将它们复制到你的某个地方蟒蛇路径.... [因为] 运行安装脚本钩子安装可执行脚本、构建 C 扩展等所必需的,这不是通过在模块中复制来完成的.

我不完全理解这一点.我一直认为这更像是一种偏好,但是安装 3rd 方模块是更好的做法是真的吗,我不这样做可能会导致问题吗?使用像 web2py 这样的框架有什么不同吗?

I don't fully understand this. I always thought it was more of a preference, but is it true that it's better practice to install 3rd party modules, and am I potentially causing problems by not doing that? Does using a framework like web2py make a difference?

推荐答案

这取决于模块以及你想用它做什么.一些软件包带有有用的命令行工具,只有在您正确安装它们后才能使用.

It depends on the module and what you want to use it for. Some packages come with useful command line tools, which may only be available to you if you install them appropriately.

相反,如果您正在编写要分发到您没有太多控制权的环境的代码,您通常必须在您的项目中本地保留一份代码副本,如目标环境可能没有该包...当然,Web 项目通常属于这一类,具体取决于您的服务环境.

Conversely, if you're writing code which is to be distributed to environments you don't have much control over, you often have to keep a copy of the code locally within your project, as the target environment may not have the package... web projects often fall into this category, depending on your serving environment, of course.

这篇关于我应该安装我的 Python 模块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 10:41