我正在尝试创建我的第一个 python 包。为了不搞砸整个交易,我一直在尝试将其上传到 testpypi 服务器。这似乎很好(sdist 创建和上传没有显示任何错误)。但是,当我尝试从 https://testpypi.python.org/pypi 将其安装到新的虚拟环境时,它提示我的安装要求,例如:
pip install -i https://testpypi.python.org/pypi poirot
Collecting poirot
Downloading https://testpypi.python.org/packages/source/p/poirot/poirot-0.0.15.tar.gz
Collecting tqdm==3.4.0 (from poirot)
Could not find a version that satisfies the requirement tqdm==3.4.0 (from poirot) (from versions: )
No matching distribution found for tqdm==3.4.0 (from poirot)
tqdm 和 Jinja2 是我唯一的要求。我尝试指定版本,而不是指定——每种方式都出错。
它似乎试图在 testpypi 服务器上找到 tqdm 和 Jinja2,但没有找到它们(因为它们仅在常规 pypi 中可用)。将包上传到非测试服务器并运行 pip install 工作。
我需要在 setup.py 文件(如下)中添加什么才能让它在上传到 testpypi 时找到需求?
谢谢!
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(name='poirot',
version='0.0.15',
description="Search a git repository's revision history for text patterns.",
url='https://github.com/dcgov/poirot',
license='https://raw.githubusercontent.com/DCgov/poirot/master/LICENSE.md',
packages=['poirot'],
install_requires=['tqdm==3.4.0', 'Jinja2==2.8'],
test_suite='nose.collector',
tests_require=['nose-progressive'],
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'
],
include_package_data=True,
scripts=['bin/big-grey-cells', 'bin/little-grey-cells'],
zip_safe=False)
最佳答案
更新
PyPI 已升级其网站。根据docs ,新的建议是:
pip install --index-url https://test.pypi.org/simple/--extra-index-url https://pypi.org/simple poirot
--index-url
指向您在 TestPyPI 上的包。--extra-index-url
指向对 PyPI 的依赖。poirot
是你的包。
过时
试试pip install --extra-index-url https://testpypi.python.org/pypi poirot
。
另见引用 post .
关于python - 从 pypi 安装 Pip 有效,但从 testpypi 失败(找不到要求),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34514703/