[英]xattr: ImportError: No module named pkg_resources
I was trying to run xattr
on macOS Catalina 10.15.2 and the error occurred:我试图在macOS Catalina 10.15.2上运行
xattr
并且出现错误:
Traceback (most recent call last):
File "/usr/bin/xattr", line 8, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
So I tried the solution given by @cwc and installed the latest version of setuptools
所以我尝试了@cwc给出的解决方案并安装了最新版本的
setuptools
pip install -U setuptools
Requirement already up-to-date: setuptools in ./opt/anaconda3/envs/general/lib/python3.7/site-packages (45.1.0)
I also installed setuptools
using pip3
我也安装
setuptools
使用pip3
pip3 install -U setuptools
Requirement already up-to-date: setuptools in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (45.1.0)
Besides, I tried the methods above in different conda
environments with Python 3.6.10 and 3.7.4 , but the problem was not solved.此外,我在不同的
conda
环境中使用 Python 3.6.10和3.7.4尝试了上述方法,但问题没有解决。 Any ideas as to this problem?关于这个问题的任何想法?
xattr
as included in Catalina uses the system-installed Python 2.7 .
Catalina 中包含的
xattr
使用系统安装的Python 2.7 。 (As shown by the head
command below.) So you need to make sure that version is set up correctly. (如下面的
head
命令所示。)所以你需要确保版本设置正确。
$ head /usr/bin/xattr
#!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Make sure python is using the system default version:确保 python 使用系统默认版本:
$ which python
/usr/bin/python
Then, run the following commands然后,运行以下命令
$ python -m ensurepip --default-pip
$ python -m pip install --upgrade pip setuptools wheel
$ python -m pip install --upgrade xattr==0.6.4
$ /usr/bin/xattr
Using pip
in this way means that the the module is being run from site-packages
directly, and will not clobber any other pip
on your system (ie from Python 3.7)以这种方式使用
pip
意味着模块直接从site-packages
运行,并且不会破坏系统上的任何其他pip
(即来自 Python 3.7)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.