Python安装机器学习sklearn库出现Error
Error:Could not install packages due to an EnvironmentError [Errno 2] No such file or directory
由 Windows 上的文件路径长度限制导致的错误
如果 Python 安装在嵌套位置(如用户主目录下的文件夹结构)中,则在达到 Windows 的默认路径大小限制时,pip 可能会无法安装包,例如:AppData
C:\Users\username>C:\Users\username\AppData\Local\Microsoft\WindowsApps\python.exe -m pip install scikit-learn
Collecting scikit-learn
…
Installing collected packages: scikit-learn
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘C:\Users\username\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\datasets\tests\data\openml\292\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz’
在这种情况下,可以使用以下工具在 Windows 注册表中取消该限制:regedit
1.