测试PyPI安装FuzzyTM遇pandas依赖缺失错误的原因及解决办法
问题:TestPyPI安装FuzzyTM时找不到pandas依赖
问题背景
我把新版本FuzzyTM包上传到TestPyPI:
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
接着用Python3.8虚拟环境测试安装,执行命令后报错:
pip install -i https://test.pypi.org/simple/ FuzzyTM==0.5.0 (test-pypi) C:\Users\Emil\surfdrive\PhD\3. Python Scripts\GitHub\FuzzyTM>pip install -i https://test.pypi.org/simple/ FuzzyTM==0.5.0 Looking in indexes: https://test.pypi.org/simple/ Collecting FuzzyTM==0.5.0 Using cached https://test-files.pythonhosted.org/packages/26/8f/7de980d5c61556e96e5277abe687f77a40cc967a8a618f0e5fc08470b492/FuzzyTM-0.5.0-py3-none-any.whl (28 kB) Collecting pyfume Using cached https://test-files.pythonhosted.org/packages/48/9e/52632652961866263f1b61b7f8c55c50992696e3cde224617a7563287d94/pyFUME-0.1.1-py3-none-any.whl (35 kB) ERROR: Could not find a version that satisfies the requirement pandas (from fuzzytm) (from versions: none) ERROR: No matching distribution found for pandas
错误原因
- TestPyPI是独立的测试仓库,里面的包数量远少于正式PyPI,像pandas这类常用包基本没有上传到TestPyPI。
- 你用
-i参数指定了仅从TestPyPI拉取所有包,pip找不到依赖的pandas,因此触发报错。
解决办法
方案1:同时指定两个源(推荐)
安装时让pip优先从TestPyPI获取FuzzyTM,其他依赖从正式PyPI拉取:
pip install -i https://test.pypi.org/simple/ FuzzyTM==0.5.0 --extra-index-url https://pypi.org/simple/
方案2:先装依赖再装包
先从正式PyPI安装完所有依赖,再单独安装TestPyPI上的FuzzyTM:
# 先安装pandas和pyfume等依赖 pip install pandas pyfume # 再安装测试版FuzzyTM pip install -i https://test.pypi.org/simple/ FuzzyTM==0.5.0
内容的提问来源于stack exchange,提问作者Emil
相关产品推荐
相关产品推荐

