Nix error when installing or uninstalling packages

Hi, I am receiving an error like this whenever I try to install or uninstall packages. It seems to be Poetry and Nix related and happens only after the environment builds Replit.nix, since the first packages installed go well; then, after 5 or 7 installed the problem appears.

cannot import name 'Mapping' from 'collections' (/nix/store/xf54awkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/collections/__init__.py)
exit status 1

It happens even when I create a new Repl.

See a similar topic:

Please provide a repl that reproduces this error.

For context, the collections API was changed in python 3.10, and earlier versions would probably show a deprecation warning.

1 Like

Hey @myqu897l, thanks for the report! I’ve got a fix in for this coming up, but for the time being I can give some context as to what’s going on.

This happens when you install a package that overrides a dependency poetry depends on. As an example:

  ImportError

  cannot import name 'Mapping' from 'collections' (/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/collections/__init__.py)

  at .pythonlibs/lib/python3.10/site-packages/html5lib/trie/_base.py:3 in <module>
        1│ from __future__ import absolute_import, division, unicode_literals
        2│ 
    →   3│ from collections import Mapping

you can see this comes from .pythonlibs/lib/python3.10/site-packages/html5lib, an old version which is incompatible with newer versions of Python.

To get Poetry working again,

$ rm -r .pythonlibs/lib/python3.10/site-packages/html5lib

after that you can remove the offending package via poetry remove or upm remove.


All this being said, you’ll still likely need to sort out the incompatible dependencies, but hopefully insight into what’s going on here helps get you closer to a resolution sooner.

4 Likes