Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package name #23

Open
mazzma12 opened this issue Jun 1, 2018 · 7 comments
Open

Package name #23

mazzma12 opened this issue Jun 1, 2018 · 7 comments

Comments

@mazzma12
Copy link

mazzma12 commented Jun 1, 2018

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

@taynaud
Copy link
Owner

taynaud commented Jun 6, 2018

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,

@mazzma12
Copy link
Author

mazzma12 commented Jun 7, 2018

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.

@pavlin-policar
Copy link
Contributor

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?

@taynaud
Copy link
Owner

taynaud commented Dec 20, 2018

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

@thisisreallife
Copy link

Problem is still unsolved in Mar, 2021

@thisisreallife
Copy link

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

@mythrandire
Copy link

mythrandire commented Oct 14, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants