python-louvain icon indicating copy to clipboard operation
python-louvain copied to clipboard

Package name

Open mazzma12 opened this issue 7 years ago • 7 comments

Why is the package listed as python-louvain but you have to use it with import community ?

  • It is misleading as people try to do pip install community
  • It shadows the name of the other community python package .

You run into troubles if you use both at the same time. Which is likely to occur if users ran pip install community in the first place

mazzma12 avatar Jun 01 '18 08:06 mazzma12

Hi,

This is only for historical reason (I start this way, not really thinking about a distribution on pypi).

I know this issue, but it is a bit complicated to change the name. For such a small package, breaking the API can be complicated.

Shadowing the community package is a bigger concern than installing python-louvain to get the community package. Do you have better idea than publishing another pypi package with the same code in another package name ?

If you do not use both 'community' package in the same software, virtual environments may be a solution ?

Best,

taynaud avatar Jun 06 '18 12:06 taynaud

Do you have better idea than publishing another pypi package with the same code in another package name ?

Yes, you can stick to your name python-louvain on the PyPi repo. You shall just add a first folder 'python_louvain' at the root that would contain the 'community' folder. This way you just have to refactor your imports into : from python_louvain import community, which is easy for every IDE.

Also to avoid adding an extra module level, you could just rename the community into python_louvain

If you do not use both 'community' package in the same software, virtual environments may be a solution ?

I totally agree about virtualenv and would use it if I had to use both packages in different projects. The problem is that people may find your package in another snippet of code and see import community and then run pip install community which will shadow the name unless they uninstall it.

mazzma12 avatar Jun 07 '18 11:06 mazzma12

To avoid backwards compatibility issues, you may want to move all the code to another module e.g. python_louvain, but also leave the community file intact for the time being, so as not to break anything that currently depends on it. So in community.py you can simply import the relevant functions from python_louvain.py. And when somebody imported community you may want to trigger a DeprecationWarning.

Then remove community altogether. This will give people depending on this library a heads up.

As a side note, are you planning a release anytime soon?

pavlin-policar avatar Dec 18 '18 08:12 pavlin-policar

I have just make a release, I will consider renaming or having both name in next version

taynaud avatar Dec 20 '18 15:12 taynaud

Problem is still unsolved in Mar, 2021

thisisreallife avatar Mar 17 '21 09:03 thisisreallife

one solution is uninstall 'community' and then install 'python_louvain' and 'networkx': https://stackoverflow.com/questions/53087066/how-to-use-the-communities-module-python-louvain-in-networkx-2-2/53101996

thisisreallife avatar Mar 17 '21 09:03 thisisreallife

Broadly, I agree with the concerns raised by @mazzma12 . Relaying my experience in this thread in case others find it after encountering the same issue.

When using pip to install python-louvain inside a Google Colab notebook, I encountered the following error:

AttributeError: module 'community' has no attribute 'best_partition'

This (also linked by @thisisreallife) suggests uninstalling community to avoid the package naming conflict discussed in this thread. It works within a virtual environment, but not on Colab.

The way I was able to use the library was directly uploading the contents of python-louvain/community/ to my Colab notebook. Then, inside of community_louvain.py, I had to change the implicit reference to community_status so that community_louvain's contents would be callable:

# from .community_status import Status
from community_status import Status

mythrandire avatar Oct 14 '21 01:10 mythrandire