python-3.x - 在自定义软件包中进行 pip 安装时,如何解决 install_requires 列表的“找不到满足要求的版本”?
问题描述
我正在尝试使用 twine 包构建我自己的 Python 包(可通过 pip 安装)。这一切都很顺利,直到我尝试 pip 安装我的实际包(所以在上传到 PyPi 之后)。
所以我首先运行:
python3 setup.py sdist bdist_wheel
我的 setup.pyinstall_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 实际install_requires
成功安装需求列表?
解决方案
你没有展示你pip install
的包裹,但我猜你正在使用类似的东西:
pip install your_project --index-url https://test.pypi.org/simple
问题是 TestPyPI 不包含 PyPI 上存在的依赖项的副本。例如:
- 存在:https ://pypi.org/project/psycopg2-binary/2.8.4/
- 不存在:https ://test.pypi.org/project/psycopg2-binary/2.8.4/
您可以将 pip 配置为在缺少包时回退到 TestPyPI,方法是指定--extra-index-url
:
pip install your_project --extra-index-url https://test.pypi.org/simple
推荐阅读
- flutter - 寻找 Flutter 的 .toImage() 方法的同步替代方案
- ios - 如何在视频中定位 CALayer?
- python - 获取 None.org.apache.spark.sql.execution.python.UserDefinedPythonFunction
- python - 将单元格值从 xlsx 导入到所有行的 python 变量
- mysql - 是否可以仅将 SMT(单消息转换)应用于来自指定主题的消息
- django - 我如何将模型字段与属于他的特定信息联系起来?
- c++ - 使用 FreeBSD 作为远程主机的 CLion 完全远程模式
- c# - 如何使用 Roslyn 在 C# 中忽略 Property Getter 和 Setter
- python - 无法添加到 lambda Python 3.6
- python - 我想预测新事件的更新次数?如何在python中做到这一点?