votes up 2

Couldn't find a tool to set the xattrs. Install either the python 'pyxattr' or 'xattr' modules, or the GNU 'attr' package (which contains the 'setfattr' tool).

Package:
Exception Class:
XAttrUnavailableError

Raise code

rr = stderr.decode('utf-8', 'replace')
                if p.returncode != 0:
                    raise XAttrMetadataError(p.returncode, stderr)

            else:
                # On Unix, and can't find pyxattr, setfattr, or xattr.
                if sys.platform.startswith('linux'):
                    raise XAttrUnavailableError(
                        "Couldn't find a tool to set the xattrs. "
                        "Install either the python 'pyxattr' or 'xattr' "
                        "modules, or the GNU 'attr' package "
                        "(which contains the 'setfattr' tool).")
                else:
                    raise XAttrUnavailableError(
                        "Couldn't find a tool to set the xattrs. "
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 1 votes down

Summary:

This exception occurs if the write_xattr function is called from youtube_dl.utils and the library xattr has not been installed in the environment that the code is being run in. The function attempts to import xattr, so if pyxattr has not been previously installed the exception occurs.

Code to Reproduce the Error if pyxattr is not installed:

from youtube_dl.utils import write_xattr
write_xattr("existingFile.txt", "key", "val")

Error Message:

FileNotFoundError                         Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/youtube_dl/utils.py in write_xattr(path, key, value)
   5687         try:
-> 5688             setxattr(path, key, value)
   5689         except EnvironmentError as e:

FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:

XAttrMetadataError                        Traceback (most recent call last)

1 frames
/usr/local/lib/python3.7/dist-packages/youtube_dl/utils.py in write_xattr(path, key, value)
   5688             setxattr(path, key, value)
   5689         except EnvironmentError as e:
-> 5690             raise XAttrMetadataError(e.errno, e.strerror)
   5691 
   5692     except ImportError:

XAttrMetadataError: No such file or directory

If you are working on Jupyter notebook, you can solve the issue by running:

!pip install pyxattr

If you are working on a file stored on your computer, you can install it by running the following in the terminal or command prompt:

pip install pyxattr

If that doesn't work, try:

pip3 install pyxattr

Once it is successfully installed, the following code will no longer yield the exception:

from youtube_dl.utils import write_xattr
write_xattr("existingFile.txt", "key", "val")
Aug 02, 2021 codingcomedyig answer

Add a possible fix

Please authorize to post fix