python - 无法安装我自己的 PyPi 包:无法满足要求
问题描述
我正在尝试发布一个 PyPI 包。我首先上传到TestPyPI进行测试。我setup.py
的很简单:
import pathlib
from setuptools import setup, find_packages
# The directory containing this file
HERE = pathlib.Path(__file__).parent
# The text of the README file
README = (HERE / "README.md").read_text()
# This call to setup() does all the work
setup(
name="my_package_name",
version="0.0.1",
description="My first Python package",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/my_package_url",
author="John Smith",
author_email="john.smith@gmail.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
],
packages=find_packages(exclude=("test",)),
include_package_data=True,
install_requires=[
"numpy",
"scipy",
"pandas",
"statsmodels",
],
)
我正在关注本教程。基本上,一旦setup.py
准备好,我就跑
python3 setup.py sdist bdist_wheel
然后
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
最后,为了实际测试我的包安装,我创建了一个新的虚拟环境并运行
pip install -i https://test.pypi.org/simple/ my_package_name
但是,我不断收到与不满足要求相关的pandas
错误statsmodels
:
ERROR: Could not find a version that satisfies the requirement pandas (from my_package_name) (from versions: none)
ERROR: No matching distribution found for pandas (from my_package_name)
是因为 TestPyPI 没有那些包(不像 PyPI)吗?那么人们通常如何端到端测试他们的包可以被其他用户顺利安装呢?
解决方案
您只能拥有一个索引,但您可以拥有任意数量的额外索引。添加主 PyPI 作为额外索引:
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ my_package_name
首先pip
查看索引,然后扫描额外的索引,直到找到包。
推荐阅读
- spring - Thymeleaf 405 Request method 'POST' not supported
- ios - iOS如何创建倒计时时间[小时,分钟,秒] Swift 4
- javascript - 为什么我的按钮不触发计时器?
- html - 移动和桌面的 div 都一样
- sql-server - 如何使用动态枢轴使一个月中的日期显示为列-明确提到了月份
- python - Django项目使用nginx和uwsigi发布后报错
- angular - Jasmine 测试用例无法读取未定义的属性“关闭”
- angular-forms - 如何获取 ngformio 的 html 包含数据组件?
- c# - 如何在 .Net 中使用 SQLCipher
- r - sapply 的替代品