Failed to build pytorch Installing collected packages: pytorch, torchvision Running setup.py install for pytorch ... error error: subprocess-exited-with-error × Running setup.py install for pytorch did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "<string>", line 36, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "D:\Temp\pip-install-q_e2d0au\pytorch_d1f7371a19d8483b82d99b851a06bcb6\setup.py", line 11, in <module> raise Exception(message) Exception: You tried to install "pytorch". The package named for PyTorch is "torch" [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> pytorch note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
时间: 2024-01-24 12:05:14 浏览: 444
这个错误提示是由于你在安装 PyTorch 时使用了错误的包名。正确的包名是 "torch" 而不是 "pytorch"。你可以使用以下命令安装 PyTorch:
```python
pip install torch torchvision
```
如果你已经安装了 PyTorch,可以使用以下命令卸载它:
```python
pip uninstall pytorch
```
然后再重新安装一次即可。
相关问题
Collecting face_recognition Using cached face_recognition-1.3.0-py2.py3-none-any.whl (15 kB) Requirement already satisfied: Pillow in d:\anaconda\envs\pytorch\lib\site-packages (from face_recognition) (9.4.0) Requirement already satisfied: face-recognition-models>=0.3.0 in d:\anaconda\envs\pytorch\lib\site-packages (from face_recognition) (0.3.0) Collecting dlib>=19.7 Using cached dlib-19.24.1.tar.gz (3.2 MB) Preparing metadata (setup.py) ... done Requirement already satisfied: Click>=6.0 in d:\anaconda\envs\pytorch\lib\site-packages (from face_recognition) (8.1.3) Requirement already satisfied: numpy in d:\anaconda\envs\pytorch\lib\site-packages (from face_recognition) (1.24.2) Requirement already satisfied: colorama in d:\anaconda\envs\pytorch\lib\site-packages (from Click>=6.0->face_recognition) (0.4.6) Building wheels for collected packages: dlib Building wheel for dlib (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [7 lines of output] running bdist_wheel running build running build_py running build_ext ERROR: CMake must be installed to build dlib [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib, face_recognition Running setup.py install for dlib ... error error: subprocess-exited-with-error × Running setup.py install for dlib did not run successfully. │ exit code: 1 ╰─> [9 lines of output] running install D:\anaconda\envs\pytorch\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py running build_ext ERROR: CMake must be installed to build dlib [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> dlib note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
这是一个安装dlib和face_recognition库时遇到的错误。根据错误输出,需要安装CMake才能构建dlib。你可以尝试通过以下命令安装CMake:
```
pip install cmake
```
然后再重新安装dlib和face_recognition库即可。
ooking in indexes: https://mirrors.aliyun.com/pypi/simple/ Collecting PyTorch Downloading https://mirrors.aliyun.com/pypi/packages/ee/67/f403d4ae6e9cd74b546ee88cccdb29b8415a9c1b3d80aebeb20c9ea91d96/pytorch-1.0.2.tar.gz (689 bytes) Preparing metadata (setup.py) ... done Building wheels for collected packages: PyTorch Building wheel for PyTorch (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install-r4o8v39w/pytorch_457f0152e72341b5b9b07d499bcd964b/setup.py", line 15, in <module> raise Exception(message) Exception: You tried to install "pytorch". The package named for PyTorch is "torch" [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for PyTorch Running setup.py clean for PyTorch Failed to build PyTorch ERROR: Could not build wheels for PyTorch, which is required to install pyproject.toml-based projects 怎么处理?
根据错误信息显示,你尝试安装的是名为“PyTorch”的包,但是正确的包名是“torch”。可以通过以下步骤解决这个问题:
1. 确认你要安装的 PyTorch 版本,访问官方网站或者文档,查看正确的包名和安装方法。
2. 使用正确的包名尝试重新安装 PyTorch。建议使用命令行安装,可以在终端中输入以下命令:
```
pip install torch
```
3. 如果仍然无法安装成功,可以尝试使用其他镜像源,例如清华大学镜像源:
```
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch
```
希望这些方法能够帮助你解决问题。
阅读全文