使用 pip 安装软件包会得到 "DuplicateOptionError"
Package installation using pip gives "DuplicateOptionError"
大家好,我在 M1 mac 上 python 版本 3.9.6
每当我尝试“pip install package”时,我都会收到以下错误(在虚拟环境内部或外部):
ERROR: Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
status = run_func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
return func(self, options, args)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 255, in run
options.use_user_site = decide_user_install(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 666, in decide_user_install
if site_packages_writable(root=root_path, isolated=isolated_mode):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 612, in site_packages_writable
for d in set(get_lib_location_guesses(root=root, isolated=isolated))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 598, in get_lib_location_guesses
scheme = get_scheme(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/init.py", line 208, in get_scheme
old = _distutils.get_scheme(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 130, in get_scheme
scheme = distutils_scheme(dist_name, user, home, root, isolated, prefix)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 46, in distutils_scheme
d.parse_config_files()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 406, in parse_config_files
parser.read(filename)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/configparser.py", line 697, in read
self._read(fp, filename)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/configparser.py", line 1096, in _read
raise DuplicateOptionError(sectname, optname,
configparser.DuplicateOptionError: While reading from '/Users/ayusharma/.pydistutils.cfg' [line 3]: option 'include_dirs' in section 'build_ext' already exists
即使我尝试使用命令“python3.9 -m venv tvenv”创建一个新的 venv:
Error: Command '['/Users/ayusharma/Desktop/Textractor/tvenv/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
由于这个问题,我无法安装任何 python 库,有人知道如何解决这个问题吗?
我找到了解决方案...
配置文件,即 '/Users/ayusharma/.pydistutils.cfg'
有两个相似的键,导致 DuplicateOptionError
所以我进入文件并删除了重复的行,这解决了我的问题。
只需进入配置文件:
vim /Users/ayusharma/.pydistutils.cfg (or any editor you use)
检查是否有重复行,如果有则删除一个。
大家好,我在 M1 mac 上 python 版本 3.9.6 每当我尝试“pip install package”时,我都会收到以下错误(在虚拟环境内部或外部):
ERROR: Exception: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper status = run_func(*args) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper return func(self, options, args) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 255, in run options.use_user_site = decide_user_install( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 666, in decide_user_install if site_packages_writable(root=root_path, isolated=isolated_mode): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 612, in site_packages_writable for d in set(get_lib_location_guesses(root=root, isolated=isolated)) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 598, in get_lib_location_guesses scheme = get_scheme( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/init.py", line 208, in get_scheme old = _distutils.get_scheme( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 130, in get_scheme scheme = distutils_scheme(dist_name, user, home, root, isolated, prefix) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_internal/locations/_distutils.py", line 46, in distutils_scheme d.parse_config_files() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 406, in parse_config_files parser.read(filename) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/configparser.py", line 697, in read self._read(fp, filename) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/configparser.py", line 1096, in _read raise DuplicateOptionError(sectname, optname, configparser.DuplicateOptionError: While reading from '/Users/ayusharma/.pydistutils.cfg' [line 3]: option 'include_dirs' in section 'build_ext' already exists
即使我尝试使用命令“python3.9 -m venv tvenv”创建一个新的 venv:
Error: Command '['/Users/ayusharma/Desktop/Textractor/tvenv/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
由于这个问题,我无法安装任何 python 库,有人知道如何解决这个问题吗?
我找到了解决方案...
配置文件,即 '/Users/ayusharma/.pydistutils.cfg'
有两个相似的键,导致 DuplicateOptionError
所以我进入文件并删除了重复的行,这解决了我的问题。
只需进入配置文件:
vim /Users/ayusharma/.pydistutils.cfg (or any editor you use)
检查是否有重复行,如果有则删除一个。