我编写了一个脚本,使用 module 为某些文件设置扩展属性xattr。我在 Ubuntu 的 python3 中成功测试了它,但它在我的 RasperryPi 上不起作用。
我不得不更改几十个小错误,其中大部分是xattr not knowing its methods.
例如xattr.set(...) has to be changed to xattr.setattr(...). 但我未能列出它们。所以我尝试了基础知识并得到了错误:
import xattr
xattr.list('files.py')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'xattr' has no attribute 'list'
Run Code Online (Sandbox Code Playgroud)
我的想法是 python 使用了错误的模块(对于 python 2.7 而不是 3?)。所以我尝试卸载 2.7 模块,但得到了这个:
...$ pip uninstall xattr
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module …Run Code Online (Sandbox Code Playgroud)