繁体   English   中英

Pip 从 pypi 安装有效,但从 testpypi 安装失败(找不到要求)

[英]Pip install from pypi works, but from testpypi fails (cannot find requirements)

我正在尝试创建我的第一个 python 包。 为了不搞砸整个交易,我一直在尝试将其上传到 testpypi 服务器。 这似乎没问题(sdist 创建和上传没有显示任何错误)。 但是,当我尝试从https://testpypi.python.org/pypi将它安装到新的 virtualenv 时,它会抱怨我的安装要求,例如:

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 已升级其网站。 根据文档,新建议是:

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

另请参阅参考帖子

在 2021 年 1 月尝试,已接受答案中的更新对我不起作用。 这有效:

pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple <your_package_in_testpypi>

请注意,第一个 URL 是test.pypi.org/pypi ,第二个是pypi.org/simple

他们的官方页面应该更新,其说明显示:

pip install -i https://test.pypi.org/simple/ <your_package_in_testpypi>

这是行不通的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM