jongracecox / anybadge

A Python project for generating badges for your projects, with a focus on simplicity and flexibility.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: cannot import name 'get_template' from 'anybadge.templates' (unknown location)

bear24rw opened this issue · comments

Recently just started getting this error in my linux CI jobs and am also able to reproduce it locally on macOS

% python3 -m anybadge
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/opt/homebrew/Cellar/python@3.10/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/opt/homebrew/lib/python3.10/site-packages/anybadge/__init__.py", line 2, in <module>
    from .badge import Badge
  File "/opt/homebrew/lib/python3.10/site-packages/anybadge/badge.py", line 13, in <module>
    from .templates import get_template
ImportError: cannot import name 'get_template' from 'anybadge.templates' (unknown location)
% python3 -m pip show anybadge
Name: anybadge
Version: 1.11.0
Summary: Simple, flexible badge generator for project badges.
Home-page: https://github.com/jongracecox/anybadge
Author: Jon Grace-Cox
Author-email: jongracecox@gmail.com
License:
Location: /opt/homebrew/lib/python3.10/site-packages
Requires: packaging
Required-by:
% python3 --version
Python 3.10.5

Screen Shot 2022-08-09 at 2 04 19 PM
It appear that the anybadge version 1.11.0 package in pypi does not contains any codes for templates package.

I'm using the following in a cicd pipeline, and all of my tests failed tonight:

- apt-get update
- apt-get install python3-pip
- pip install anybadge
anybadge --label='mylabel' --value='myvalue' --file='my.svg' --color=yellow

Same error as above.

We are having the same problem here

Traceback (most recent call last):
  File "/usr/local/bin/anybadge", line 5, in <module>
    from anybadge.cli import main
  File "/usr/local/lib/python3.9/site-packages/anybadge/__init__.py", line 2, in <module>
    from .badge import Badge
  File "/usr/local/lib/python3.9/site-packages/anybadge/badge.py", line 13, in <module>
    from .templates import get_template
ImportError: cannot import name 'get_template' from 'anybadge.templates' (unknown location)

We are using python 3.9. Any work-around for the moment?

As @michjk reported the problem is in the package. The workaround is to use the previous stable version (1.9.0).

Downgrade to 1.9.0 works as a workaround

pip install anybadge==1.9.0

commented

Yes same issue here, luckily our tests were/are failing so we didn't upgrade yet.

Yes can confirm the new version destroyed the our GitLab jobs at our company.
Hard coding version 1.9.0 fixes the problem.

Pushing fix now.

You have my sincere apologies for the broken version and the impact it has had on your projects. I have fixed the package build and have deployed 1.11.1 to PyPi, so will close the issue out. The CI tests for this package run against the source code, not against the wheel, so the tests didn't detect the issue. I will plan to switch the tests to run against the package file instead of the source code.

You have my sincere apologies for the broken version and the impact is has had on your projects. I have fixed the package build and have deployed 1.11.1 to PyPi, so will close the issue out. The CI tests for this package run against the source code, not against the wheel, so the tests didn't detect the issue. I will plan to switch the tests to run against the package file instead of the source code.

No worries man - it happens to everyone. Thanks for your ongoing efforts in maintaining this project.

commented

Exactly, thanks for the quick fix!

You do a great job !