在自定义程序包中进行pip安装时,如何解决install_requires列表的“找不到满足要求的版本”?

问题描述

我正在尝试使用twine软件包构建自己的Python软件包(可通过pip安装)。一切顺利,直到我尝试通过pip安装我的实际软件包为止(因此,在上传到PyPi之后)。

所以我首先运行:

python3 setup.py sdist bdist_wheel

其中的setup.py install_requires列表如下:

install_requires=[
'jupyter_kernel_gateway==2.4.0','pandas==1.0.2','numpy==1.18.1','azure-storage-blob==2.0.1','azure-datalake-store==0.0.48','psycopg2-binary==2.8.4','xlsxwriter==1.2.6','SQLAlchemy==1.3.12','geoalchemy2==0.6.3','tabulate==0.8.2','pyproj==1.9.6','geopandas==0.4.0','contextily==0.99.0','matplotlib==3.0.2','humanize==0.5.1','ujson==1.35','singleton-decorator==1.0.0','dataclasses==0.6','xlrd==1.2.0'],

据我了解,这些install_requires将在安装我自己的软件包时由pip安装。

此后我运行

python3 -m twine upload --repository testpypi dist/*

实际将我的包上传到PyPi。但是,在pip安装我的软件包时,出现错误,提示没有满足许多所列要求的版本。例如:ERROR: Could not find a version that satisfies the requirement psycopg2-binary==2.8.4

当我手动安装这些软件包(例如pip install psycopg2-binary==2.8.4)时,它们确实已安装。

有什么方法可以使我的软件包的pip安装成功地成功安装install_requires需求列表吗?

解决方法

您没有显示如何pip install-放入包裹,但是我猜您正在使用类似的东西:

pip install your_project --index-url https://test.pypi.org/simple

问题是TestPyPI不包含PyPI上存在的依赖项副本。例如:

您可以通过指定--extra-index-url来配置pip,使其在缺少包时退回到TestPyPI上:

pip install your_project --extra-index-url https://test.pypi.org/simple 

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...