How to handle python packages with conflicting names?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 04:56:05

You could use the --target option for pip and install to an alternate location:

pip install --target=/tmp/test/lib/python3.6/site-packages/alt_alembic alembic

Then when you import in python, do the first as usual and for the alt do an import from that namespace like this:

import alembic  # alembic.io version
from alt_alembic import alembic as alt_alembic  # pip version

Then when you're making calls to that one you can call alt_alembic.function() and to the one that isn't in PyPi, alembic.function() My target path has /tmp/test as I was using a virtual env. You would need to replace that path with the correct one for your python installation.

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