Resolve conflicting package names in Python

元气小坏坏 提交于 2020-01-30 03:54:48

问题


Let's say we have two different Python packages from the same vendor, named with the same name -- foo. One is installed with pip and can be found in the /usr/lib/python/site-packages/foo directory, the second one is a system-wide dependency which you install with e.g. apt-get and the Python package ends up in /usr/lib/some-vendor-sdk/foo. Local and global foo do different things and I need them both to be importable in my source code, but I can only import one:

$ python
>>> import foo
>>> foo.__path__
/usr/lib/python2.7/site-packages/foo

Is there a way to make both packages importable in my code? It'd be fine to alias one of them somehow, I just don't know a technical way to do it. Any suggestions?

来源:https://stackoverflow.com/questions/59051935/resolve-conflicting-package-names-in-python

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