How to install the Python module from Local using Pip?

Shape Image One

How to install the Python module from Local using Pip?

We all know, Pip is the best and the most popular tool to install and manage Python modules on your system.

Just like we can install Python packages from the remote repository, we can also install Python modules from the local directory on your system.

Install Python module from local directory using pip

Here is the command. With this, you can install Python modules from a local directory using pip.

pip install /path/to/module/directory

Here /path/to/module/directory is a placeholder, nothing but the path to the directory where the Python module is present on your system.

If you are already inside the Python module directory, you can just provide . as the path.

pip install .

If you check the installed Python packages, you will see the newly installed module.

But now, the problem is that, if you make any change in the Python module code, the installed Python module will have the old code running. Every time, if you make any changes to the Python module, whether it is a small or big change, you have to install the Python module again with the same command mentioned above.

Install Python Package in Editable Mode

Alternatively, use the -e flag option in the above pip install command. This will install the Python module in editable mode.

pip install -e /path/to/module/directory

Again, here, /path/to/module/directory is the actual path to the directory where your module is located.

Now you can make the changes in the Python module and changes will be reflected. You don’t need to install the Python module again.

I found this pip install command with editable mode very useful when I was developing a Python package module locally.

This allows you to make changes to the module code and have those changes reflected immediately without reinstalling the module.

Leave a Reply

Your email address will not be published. Required fields are marked *