How to Install two python modules with same name?


This is not possible with the pip. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change. Even if you manage to put the code on Python path, when importing a module, python searches the paths in sys.path by order and stops at first match. So whatever module it finds first, it'll stop at that. 

You best bet is to copy all the code from the libraries to you codebase, change the module name of either and then import it.

If you're importing modules with same name from different packages, you can do it as follows:

>>> from foo import bar as first_bar
>>> from baz import bar as second_bar

Updated on: 01-Oct-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements