Medical Data Visualizer on Replit

I can’t run the tests on replit (it seems it updates the packages to a lower version, but nothing works. Also from the shell there are missing libraries). I run it locally and I get two failures:

ERROR: test_bar_plot_number_of_bars (test_module.CatPlotTestCase.test_bar_plot_number_of_bars)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/mobile/Library/Mobile Documents/iCloud~AsheKube~app~a-Shell/Documents/boilerplate-medical-data-visualizer/tes
t_module.py", line 26, in test_bar_plot_number_of_bars
    actual = len([rect for rect in self.ax.get_children() if isinstance(rect, mpl.patches.Rectangle)])
                                   ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'numpy.ndarray' object has no attribute 'get_children'
======================================================================
ERROR: test_line_plot_labels (test_module.CatPlotTestCase.test_line_plot_labels)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/mobile/Library/Mobile Documents/iCloud~AsheKube~app~a-Shell/Documents/boilerplate-medical-data-visualizer/tes
t_module.py", line 13, in test_line_plot_labels
    actual = self.ax.get_xlabel()
             ^^^^^^^^^^^^^^^^^^
AttributeError: 'numpy.ndarray' object has no attribute 'get_xlabel'
----------------------------------------------------------------------
Ran 4 tests in 0.939s
FAILED (errors=2)

I need some help with this challenge.

Check my project here.

At least on the versioning bit, you need to go into the poetry.lock file and change the version numbers to whatever it’s trying to downgrade to. Otherwise it will downgrade everytime you click “Run” and that takes forever.

And any missing packages you’ll have to go into the shell and pip install [package name]. Sorry, Replit can be annoying to work with.

As for the specific “object has no attribute” error, check out this thread:

Thanks. I’ve copied poetry.lock from the python replit template and at least it works and I’ve been able to finish the project :slight_smile:

Editing poetry.lock is a bad idea even if it works as it is generated by poetry and shouldn’t be edited, much like package-lock.json or yarn.lock.

This was likely another case of the oft discussed dependency version problem of the python data analysis projects which should be fixed by editing pyproject.toml and updating packages.

Looking at the OP’s linked repl, I’m astonished that it works. The code appears to use seaborn but seaborn is not mentioned in pyproject.toml, poetry.lock, or the replit package tool so I’m unsure as to how it’s loaded and executes to pass the tests.

I’m running all the tests from the replit shell, so at least I have had complete the projects, but I’ve been having this problem with all the Data Analysis series, so it should be definitely check by freeCodeCamp,…

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.