问题描述
今天在执行pip install qpth时,遇到了以下bug:
$ pip install qpth
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting qpth
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/e1/d5/cb0aefa287767726e6e20b0b3774517feaaca11c775c0069824b4c68d1e8/qpth-0.0.15.tar.gz (11 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [3 lines of output]
error in qpth setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected end or semicolon (after version specifier)
numpy>=1<2
~~~^
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─> See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
这说明qpth的setup.py写的有问题。博主本来想找到下载下来的tar.gz解包后再修改的,奈何执行全局搜索也没有找到qpth相关的包,执行
conda run python -m pip cache dir
返回/root/.cache/pip,在这个文件夹里也没有找到。决定按照报错提供的链接地址下载后上传至服务器,修改setup.py后手动pip。
解决方案
下载链接:
将该压缩包上传至服务器并使用以下命令解压缩:
tar -vxzf qpth-0.0.15.tar.gz
进入该文件夹,打开setup.py文件,将报错中的
numpy>=1<2
改为
numpy>=1
然后执行
python setup.py install
成功安装qpth。