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

No module named 'pkg_resources' #148

Open
carissableker opened this issue Feb 25, 2025 · 6 comments
Open

No module named 'pkg_resources' #148

carissableker opened this issue Feb 25, 2025 · 6 comments

Comments

@carissableker
Copy link

This is a note in case other users come across a similar issue before it is fixed by colorbrewer

In a fresh install with Python 3.13.2

I got the following error:

import py4cytoscape as p4c
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 import py4cytoscape as p4c

File [~/miniconda3/envs/test-install/lib/python3.13/site-packages/py4cytoscape/__init__.py:38](http://localhost:8888/home/cbleker/miniconda3/envs/test-install/lib/python3.13/site-packages/py4cytoscape/__init__.py#line=37)
     36 from .styles import *
     37 from .style_mappings import *
---> 38 from .style_auto_mappings import *
     39 from .style_defaults import *
     40 from .style_values import *

File [~/miniconda3/envs/test-install/lib/python3.13/site-packages/py4cytoscape/style_auto_mappings.py:29](http://localhost:8888/home/cbleker/miniconda3/envs/test-install/lib/python3.13/site-packages/py4cytoscape/style_auto_mappings.py#line=28)
     12 """Copyright 2020-2022 The Cytoscape Consortium
     13 
     14 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
   (...)
     25 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     26 """
     28 # External library imports
---> 29 import colorbrewer
     30 import random
     31 import numpy as np

File [~/miniconda3/envs/test-install/lib/python3.13/site-packages/colorbrewer/__init__.py:17](http://localhost:8888/home/cbleker/miniconda3/envs/test-install/lib/python3.13/site-packages/colorbrewer/__init__.py#line=16)
     13 # Copyright 2009, 2012 Michael M. Hoffman <mmh1@washington.edu>
     15 from collections import defaultdict
---> 17 from pkg_resources import resource_string
     18 from csv import DictReader, reader as csv_reader
     20 try:
     21     # Python 2.6+

ModuleNotFoundError: No module named 'pkg_resources'

This is due to pkg_resources being deprecated and then removed in Python 3.12: https://setuptools.pypa.io/en/latest/pkg_resources.html https://docs.python.org/3/whatsnew/3.12.html

pkg_resources is not a direct dependency of py4cytoscape, but of colorbrewer (PyPi: https://pypi.org/project/colorbrewer/).

Since there is no GitHub or working project page of colorbrewer, I am have reached out directly to ask that they update, and will update/close this issue if I hear back.


Temporary fix

pip install --upgrade setuptools 
@bdemchak
Copy link
Collaborator

@carissableker ... thanks for pointing this out, and double-thanks for the workaround!

Certainly, it's time to move on from colorbrewer ... I guess this happens from time to time.

A quick look at PyPI indicates that https://pypi.org/project/palettable/ may be a reasonable path. I'll give a deeper look later today. I'll be looking for something that works with >= Python 3.8 without major trauma to the py4cytoscape source or unit tests. (Fortunately, the unit tests set some good guard rails for demonstrating correctness.)

Feel free to comment or offer alternatives.

Thanks!

@bdemchak
Copy link
Collaborator

@carissableker ... my approach was to create my own copy of colorbrewer and use it directly ... and then eliminate references to the colorbrewer package. I have this working on my development machine, and will release it once it's properly tested. Thanks again!

@carissableker
Copy link
Author

In case you want to keep with colorbrewer, the developers there have responded and made the repository public here:

https://github.com/hoffmangroup/colorbrewer

It seems they plan to update it.

@bdemchak
Copy link
Collaborator

@carissableker Indeed, they have updated it far more quickly than I expected. In the meantime, there are a number of other Python 3.13.2 issues in py4cytoscape, too. I have addressed them and am now doing regression testing. Please stand by.

@bdemchak
Copy link
Collaborator

@carissableker Please try out my working copy of py4cytoscape in the 1.12.0 branch, which isn't released to Master yet. It now uses the 0.3.0 Colorbrewer module. Thanks for enlisting those maintainers to update this module!

@carissableker
Copy link
Author

Seems all good now!

conda create -n p4c-1.12.0 python=3.13
conda activate p4c-1.12.0
pip install "py4cytoscape @ git+ssh://git@github.com/cytoscape/py4cytoscape.git@1.12.0"

...
Successfully installed backoff-2.2.1 certifi-2025.1.31 chardet-5.2.0 charset-normalizer-3.4.1 colorbrewer-0.3 colour-0.1.5 decorator-5.2.1 idna-3.10 igraph-0.11.8 networkx-3.4.2 numpy-2.2.3 pandas-2.2.3 py4cytoscape-1.12.0 python-dateutil-2.9.0.post0 pytz-2025.1 requests-2.32.3 six-1.17.0 texttable-1.7.0 tzdata-2025.1 urllib3-2.3.0

python --version

Python 3.13.2

python -c 'import py4cytoscape as p4c; print("Yay!")'

Yay!

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

2 participants