How to install python package with a different name using PIP

PythonDuplicatesPackagePip

Python Problem Overview


When installing a new python package with PIP, can I change the package name because there is another package with the same name?

Or, how can I change the existing package's name?

Python Solutions


Solution 1 - Python

It's not possible to change "import path" (installed name) by specifying arguments to pip. All other options require some form of "changes to the package":

A. Use pip install -e git+http://some_url#egg=some-name: that way even if both packages have the same import path, they will be saved under different directories (using some-name provided after #egg=). After this you can go to the source directories of packages (usually venv/src/some-name) and rename some folders to change import paths

B-C. Fork the repository, make changes, then install the package from that repository. Or you can publish your package on PyPI using different name and install it by name

D. use pip download to put one of the packages in your project, then rename folders as you like

Solution 2 - Python

I think one way of going about this can be using

pip download

See the docs here. You can change the name of the package after it has been downloaded and then go about manually installing it. I haven't tested this but seems like it should work.

Solution 3 - Python

Create a new virtualenv and then install the package on new virtualenv, with this you can have the different version of packages as well.

Solution 4 - Python

If you are struggling to install the correct package when using pip install 'module', you could always download its corresponding wheel file (.whl extension) and then install this directly using pip. This has worked for me in various situations in the past.

Solution 5 - Python

Use virtualenv if you don't need both package for the same project. With virtualenv you can have different version of packages as well.

Another way maybe the site-packages as mentioned already.

https://virtualenv.pypa.io/en/stable/

http://docs.python-guide.org/en/latest/dev/virtualenvs/#lower-level-virtualenv

Solution 6 - Python

I had this problem with the libraries gmail and pygmail, they both want to install to PYTHONPATH/site-packages/gmail/. Clearly the pygmail package has an issue, it should be installing to pygmail folder, but they haven't made any updates in years.

For an interim solution, I installed one (pygmail), then changed the folder names (gmail-->pygmail, and gmail-v#.dist-info-->pygmail-v#.dist-info), then installed the second one normally. Seems to work, as long as I don't try to update the first package. import gmail and import pygmail work as expected.

Solution 7 - Python

I'm guessing that at least one of the packages you refer is not installed from https://pypi.org/ since they enforce unique names for the packages; this means you're installing that package from source, which means you also have the freedom of changing its name to whatever you want. You would do this by changing the setup.py file in the root of the offending package.

Solution 8 - Python

I Don't think it is possible to change the name of package by using pip. Because pip can install packages which are exist and gives error if there is no package name which you write for change the name of package.

Solution 9 - Python

This is not possible with the pip command line tool. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3562812View Question on Stackoverflow
Solution 1 - PythonimposerenView Answer on Stackoverflow
Solution 2 - PythonunixiaView Answer on Stackoverflow
Solution 3 - PythonRazia KhanView Answer on Stackoverflow
Solution 4 - PythonRob123View Answer on Stackoverflow
Solution 5 - PythonBenjámin GervánView Answer on Stackoverflow
Solution 6 - PythonErock618View Answer on Stackoverflow
Solution 7 - PythonvlsdView Answer on Stackoverflow
Solution 8 - PythonPooaView Answer on Stackoverflow
Solution 9 - PythonAlexMengView Answer on Stackoverflow