重新复现代码,一个报错本来更改pip版本就可以解决,整了半天浪费时间了⛔

WARNING: Ignoring version 1.6.0 of pytorch_lightning since it has
invalid metadata: Requested pytorch_lightning1.6.0 from
https://files.pythonhosted.org/packages/09/18/cee67f4849dea9a29b7af7cdf582246bcba9eaa73d9443e138a4172ec786/pytorch_lightning-1.6.0-py3-none-any.whl
(from -r requirements.txt (line 17)) has invalid metadata: .* suffix
can only be used with == or != operators
torch (>=1.8.*)
~~~~~~^ Please use pip<24.1 if you need to use this version. ERROR: Ignored the following versions that require a
different python version: 0.22.0 Requires-Python >=3.9; 0.22.0rc1
Requires-Python >=3.9; 0.23.0 Requires-Python >=3.10; 0.23.0rc0
Requires-Python >=3.10; 0.23.0rc2 Requires-Python >=3.10; 0.23.1
Requires-Python >=3.10; 0.23.2 Requires-Python >=3.10; 0.23.2rc1
Requires-Python >=3.10; 0.24.0 Requires-Python >=3.9; 0.24.0rc1
Requires-Python >=3.9; 0.25.0 Requires-Python >=3.10; 0.25.0rc0
Requires-Python >=3.10; 0.25.0rc1 Requires-Python >=3.10; 0.25.0rc2
Requires-Python >=3.10; 0.25.1 Requires-Python >=3.10; 0.25.2
Requires-Python >=3.10; 0.25.2rc0 Requires-Python >=3.10; 0.6.0
Requires-Python >=3.9; 2.36.0 Requires-Python >=3.9; 2.36.1
Requires-Python >=3.9; 2.37.0 Requires-Python >=3.9; 2.5.0
Requires-Python >=3.9; 2.5.0.post0 Requires-Python >=3.9; 2.5.0rc0
Requires-Python >=3.9; 2.5.1 Requires-Python >=3.9; 2.5.1rc0
Requires-Python >=3.9; 2.5.1rc1 Requires-Python >=3.9; 2.5.1rc2
Requires-Python >=3.9; 3.10.0 Requires-Python >=3.10; 3.10.0rc1
Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.8.0
Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1
Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3
Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9.0
Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1
Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2
Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4
Requires-Python >=3.9 ERROR: Could not find a version that satisfies
the requirement pytorch_lightning
1.6.0 (from versions: 0.0.2, 0.2,
0.2.2, 0.2.3, 0.2.4, 0.2.4.1, 0.2.5, 0.2.5.1, 0.2.5.2, 0.2.6, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.4.1, 0.3.5, 0.3.6, 0.3.6.1, 0.3.6.3, 0.3.6.4, 0.3.6.5, 0.3.6.6, 0.3.6.7, 0.3.6.8, 0.3.6.9, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.5.0, 0.5.1, 0.5.1.2, 0.5.1.3, 0.5.2, 0.5.2.1, 0.5.3, 0.5.3.1, 0.5.3.2, 0.5.3.3, 0.6.0, 0.7.1, 0.7.3, 0.7.5, 0.7.6, 0.8.1, 0.8.3, 0.8.4, 0.8.5, 0.9.0, 0.10.0, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.2.8, 1.2.9, 1.2.10, 1.3.0rc1, 1.3.0rc2, 1.3.0rc3, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.7.post0, 1.3.8, 1.4.0rc0, 1.4.0rc1, 1.4.0rc2, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.10.post0, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.5.post0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.8.0rc0, 1.8.0rc1, 1.8.0rc2, 1.8.0, 1.8.0.post1, 1.8.1, 1.8.2, 1.8.3, 1.8.3.post0, 1.8.3.post1, 1.8.3.post2, 1.8.4, 1.8.4.post0, 1.8.5, 1.8.5.post0, 1.8.6, 1.9.0rc0, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 2.0.0rc0, 2.0.0, 2.0.1, 2.0.1.post0, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.0.9.post0, 2.1.0rc0, 2.1.0rc1, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2.0rc0, 2.2.0, 2.2.0.post0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.4.0) ERROR: No matching distribution found for pytorch_lightning==1.6.0

上述是报错信息

ERROR: No matching distribution found for pytorch_lightning==1.6.0

起初只看见这个报错,误以为当前环境中的Python版本或PyTorch版本不兼容导致的。然后更新了pytorch版本
从更新pytorch开始就完了,开始各种报错

File “run.py”, line 28, in
from utils.select_option import select_callback, select_dataset, select_model File
“/home/uriky/桌面/update-ubuntu1/oringin/Aleth-NeRF-master/utils/select_option.py”,
line 23, in
from src.model.dvgo.model import LitDVGO File “/home/uriky/桌面/update-ubuntu1/oringin/Aleth-NeRF-master/src/model/dvgo/model.py”,
line 23, in
import src.model.dvgo.dcvgo as dcvgo File “/home/uriky/桌面/update-ubuntu1/oringin/Aleth-NeRF-master/src/model/dvgo/dcvgo.py”,
line 17, in
from torch_scatter import segment_coo File “/home/uriky/anaconda3/envs/aleth_nerf/lib/python3.8/site-packages/torch_scatter/init.py”,
line 16, in
torch.ops.load_library(spec.origin) File “/home/uriky/anaconda3/envs/aleth_nerf/lib/python3.8/site-packages/torch/_ops.py”,
line 1295, in load_library
ctypes.CDLL(path) File “/home/uriky/anaconda3/envs/aleth_nerf/lib/python3.8/ctypes/init.py”,
line 373, in init
self._handle = _dlopen(self._name, mode) OSError: libtorch_cuda_cu.so: cannot open shared object file: No such file or
directory

现在又报错cuda版本不匹配了

又重新让PyTorch 的版本必与 CUDA 版本匹配
后面出了各种问题
其实只需一步就可以解决最开始的报错,就是因为忽略了

can only be used with == or != operators

torch (>=1.8.*)
       ~~~~~~^ Please use pip<24.1 
       if you need to use this version.
        ERROR: Ignored the following versions that 
        require a different python version: 0.22.0
        Requires-Python >=3.9;

解决办法就是把pip版本降级到24.1以下

 pip install pip==24.0

切记!!!!pip 版本会影响依赖包的安装

以下为AI解释
pip 版本确实会影响依赖包的安装,原因主要有以下几点:

1. 不同版本的 pip 支持不同的功能

pip 是 Python 的包管理工具,随着版本的更新,它会引入新的功能、改进和修复。不同版本的 pip 在解析依赖关系、安装包的方式以及对包格式的支持上可能存在差异。例如:

  • 较新的 pip 版本支持 pyproject.toml 文件(PEP 517/518),而较旧版本可能不支持。
  • 较新的 pip 版本在解析依赖关系时可能更严格,能够更好地处理复杂的依赖冲突。
  • 较新的 pip 版本可能支持新的包格式或安装机制。

如果某些包依赖于 pip 的新功能,而你使用的 pip 版本较旧,可能会导致安装失败。

2. 依赖解析算法的变化

pip 在解析依赖关系时会尝试找到满足所有依赖项的版本组合。不同版本的 pip 在依赖解析算法上可能存在差异。例如:

  • 较旧版本的 pip 可能会安装较旧的依赖项版本,而较新版本的 pip 会尝试安装更新的、更兼容的版本。
  • 较新的 pip 版本在处理依赖冲突时可能更智能,能够更好地解决复杂的依赖关系。

如果某些包的依赖关系较为复杂,较旧版本的 pip 可能无法正确解析这些依赖,从而导致安装失败。

3. 对包格式的支持

pip 不断更新以支持新的包格式和安装机制。例如:

  • 较新的 pip 版本支持 wheel 格式的包(.whl 文件),而较旧版本可能只支持 source 格式的包(.tar.gz 文件)。
  • 较新的 pip 版本支持 pyproject.toml 文件,而较旧版本可能不支持。

如果某些包仅提供新的格式(如 .whl 文件),而你使用的 pip 版本较旧,可能会导致无法正确安装。

4. 对 Python 和操作系统版本的支持

pip 的不同版本对 Python 和操作系统的支持也有所不同。例如:

  • 较新的 pip 版本可能支持 Python 的新特性(如 Python 3.10 或更高版本),而较旧版本可能不支持。
  • 较新的 pip 版本可能对某些操作系统的特定问题进行了修复,而较旧版本可能存在兼容性问题。

如果某些包需要特定的 Python 或操作系统版本支持,而你使用的 pip 版本较旧,可能会导致安装失败。

5. 对依赖项版本的限制

某些包可能在 setup.pypyproject.toml 文件中指定了对依赖项版本的严格限制。例如:

install_requires=[
    "numpy>=1.20.0",
    "torch>=1.9.0",
]

较新的 pip 版本在解析这些依赖项时会更严格,确保安装的版本满足要求。而较旧版本的 pip 可能会忽略这些限制,导致安装的版本不兼容。

6. 对编译环境的要求

某些包(如 torch-scatter)需要在安装时编译,这可能依赖于特定的编译环境(如 gccnvcc 等)。不同版本的 pip 在处理编译环境时可能有所不同。例如:

  • 较新的 pip 版本可能支持更复杂的编译依赖,而较旧版本可能无法正确处理。
  • 较新的 pip 版本可能在编译时提供更多的调试信息,帮助用户解决问题。

如果某些包需要特定的编译环境,而你使用的 pip 版本较旧,可能会导致编译失败。

7. 对 PyPI 服务器的支持

pip 从 PyPI 服务器下载包,而 PyPI 服务器的格式和 API 可能会随着时间变化。较新的 pip 版本通常会支持最新的 PyPI 服务器格式,而较旧版本可能无法正确下载某些包。

8. 安全性和漏洞修复

较新的 pip 版本通常会修复已知的安全漏洞,并提供更好的安全性。如果某些包依赖于 pip 的安全性特性,而你使用的 pip 版本较旧,可能会导致安装失败。

总结

pip 版本会影响依赖包的安装,因为它在解析依赖关系、支持包格式、处理编译环境等方面可能存在差异。为了确保依赖包能够正确安装,建议使用最新版本的 pip。你可以通过以下命令更新 pip

pip install --upgrade pip

如果你遇到安装问题,可以尝试降级 pip 到较旧版本,或者根据具体问题调整 pip 版本。

你可能感兴趣的:(代码中出现的一些问题,pip)