Hie everyone, I'm on a M1 mac with a python version 3.9.6 Whenever I try to "pip install package" I get the following error(inside or outside a virtual environment):
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
Even when I try to create a new venv with the command "python3.9 -m venv tvenv":
Error: Command '['/Users/ayusharma/Desktop/Textractor/tvenv/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
I am unable to install any python library due to this issue, does anyone know how to fix this ?
I found the solution...
The configuration file i.e. '/Users/ayusharma/.pydistutils.cfg'
had two similar keys which was causing the DuplicateOptionError
So I went into the file and removed the duplicate line, which solved the issue for me.
Just go into the config file:
vim /Users/ayusharma/.pydistutils.cfg (or any editor you use)
Check for duplicate lines if any just delete one.