Windows10+Python3.8.5安装plotly遇_distutils_hack缺失错误求助
ModuleNotFoundError: No module named '_distutils_hack' When Installing Plotly on Python 3.8.5 (Windows 10) Hey there, I’ve dealt with this exact _distutils_hack error before when working with older Python versions and setuptools. Let’s walk through some practical fixes to get Plotly installed successfully:
First, Let’s Recap Your Scenario
You’re on Windows 10 running Python 3.8.5, using an admin Command Prompt. When running pip3 install plotly, the install fails while trying to set up retrying-1.3.3 with this error:
ERROR: Command errored out with exit status 1: command: 'c:\programdata\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\student\AppData\Local\Temp\pip-install-2qndeluw\retrying_de785ef56b9d4150b577dd9f4437e271\setup.py'"'"'; __file__='"'"'C:\Users\student\AppData\Local\Temp\pip-install-2qndeluw\retrying_de785ef56b9d4150b577dd9f4437e271\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\student\AppData\Local\Temp\pip-pip-egg-info-3tjoj6d_' cwd: C:\Users\student\AppData\Local\Temp\pip-install-2qndeluw\retrying_de785ef56b9d4150b577dd9f4437e271\ Complete output (5 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\programdata\python38\lib\site-packages\setuptools\__init__.py", line 8, in <module> import _distutils_hack.override # noqa: F401 ModuleNotFoundError: No module named '_distutils_hack'
Solutions to Try
1. Downgrade Setuptools to a Version Compatible with Python 3.8
Newer setuptools versions dropped support for older Python releases like 3.8, which often causes this _distutils_hack mismatch. Here’s how to fix it:
- Uninstall your current setuptools:
pip3 uninstall -y setuptools - Install a compatible version (44.0.0 works great with Python 3.8):
pip3 install setuptools==44.0.0 - Now try installing Plotly again:
pip3 install plotly
2. Install retrying Without Build Isolation
The build isolation process is sometimes the culprit here. Skip it for the retrying package first, then install Plotly:
- Install
retryingwith the--no-build-isolationflag:pip3 install retrying>=1.3.3 --no-build-isolation - Once that’s done, install Plotly normally:
pip3 install plotly
3. Upgrade Pip to the Latest Supported Version
Outdated pip can cause dependency resolution issues. Update it first:
python -m pip install --upgrade pip
Then retry the Plotly install.
4. Repair Your Python 3.8 Installation
Sometimes the built-in distutils module gets corrupted or wasn’t installed correctly:
- Locate your Python 3.8.5 installer (download it again from python.org if you don’t have it).
- Run the installer and select Modify.
- Ensure the
distutilscomponent is checked (it should be under "Optional Features"). - Click Next and follow the prompts to complete the repair.
- After repair, try installing Plotly again.
内容的提问来源于stack exchange,提问作者blizzardus

