安装两个同名的python模块
安装两个同名的 python 模块的最佳方法是什么?我目前依赖于两个不同的 facebook 库:pyfacebook 和 Facebook 的新 python-sdk。这两个库都将自身安装为模块“facebook”。我可以想到一堆 hacky 解决方案,但在我开始 hack 之前,我很好奇是否有一种 pythonic 方法来处理这种情况。
我正在使用 virtualenv 和 pip。
(是的,我最终会弃用其中一个,但我有两名不同的工程师正在研究两个不同的问题,他们在集成之前没有意识到他们正在使用不同的模块)
What's the best way to install two python modules with the same name? I currently depend on two different facebook libraries: pyfacebook and Facebook's new python-sdk. Both of these libraries install themselves as the module 'facebook'. I can think of a bunch of hacky solutions but before I go an hack away I was curious if there was a pythonic way of dealing with this situation.
I'm using virtualenv and pip.
(Yes, I will eventually deprecate one of them, but I had two different engineers working on two different problems and they didn't realize that they were using a different module until integration)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,我建议你们检查一下你们正在使用的其他库,以便您可以了解如何构建应用程序。
为了支持这种类型的事情,将每个模块放在它自己的文件夹中,放入一个 __init__.py 文件,然后你可以这样做:
First, I'd suggest you guys go over what other libraries you're all using so you can get a concesus on how you're building your application.
To support this type of thing place each module within it's own folder, put in an
__init__.py
file, then you can do this:最简单的解决方案是在项目中包含一个(或两个)模块,而不是安装它。然后,您可以更好地控制模块名称和导入。
The easiest solution would be to include one (or both) of the modules in your project instead of installing it. Then, you can have more control over the module name and importing.