Should I be installing my Python modules?

蓝咒 提交于 2019-12-11 02:10:00

问题


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.

On one of my other questions, the answerer said

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.

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?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/10761521/should-i-be-installing-my-python-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!