简体   繁体   English

安装两个同名的python模块

[英]Install two python modules with same name

What's the best way to install two python modules with the same name? 安装两个同名的python模块的最佳方法是什么? I currently depend on two different facebook libraries: pyfacebook and Facebook's new python-sdk. 我目前依赖于两个不同的facebook库:pyfacebook和Facebook的新python-sdk。 Both of these libraries install themselves as the module 'facebook'. 这两个库都将自己安装为模块“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. 我可以想到一堆hacky解决方案,但在我去黑客之前,我很好奇是否有一种pythonic方式来处理这种情况。

I'm using virtualenv and pip. 我正在使用virtualenv和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) (是的,我最终会弃用其中一个,但我有两个不同的工程师处理两个不同的问题,他们没有意识到他们使用不同的模块,直到集成)

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: 为了支持这种类型的东西,将每个模块放在它自己的文件夹中,放入__init__.py文件,然后你可以这样做:

import Folder1.facebook as pyfacebook
import Folder2.facebook as facebooksdk

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. 然后,您可以更好地控制模块名称和导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM