报错:ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\ABC\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\tensorflow\\include\\external\\com_github_grpc_grpc\\src\\core\\ext\\filters\\client_channel\\lb_policy\\grpclb\\client_load_reporting_filter.h'
HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
这个错误信息表明在尝试安装TensorFlow时遇到了文件路径长度问题。具体来说,错误信息提示“没有这样的文件或目录”,这通常是因为Windows系统中的路径长度限制导致的。在Windows系统中,传统上路径长度限制为260个字符(称为MAX_PATH限制),如果路径超过这个长度,就会导致这种错误。
解决:
win+x打开具有管理员权限的PowerShell窗口,运行
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
之后再pip install tensorflow