简体   繁体   English

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

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

I'm trying to create my first python package.我正在尝试创建我的第一个 python 包。 To not bungle the whole deal, I've been attempting to upload it to the testpypi servers.为了不搞砸整个交易,我一直在尝试将其上传到 testpypi 服务器。 That seems to go fine (sdist creates and upload doesn't show any errors).这似乎没问题(sdist 创建和上传没有显示任何错误)。 However, when I try to install it to a new virtualenv from https://testpypi.python.org/pypi , it complains about my install requirements, eg:但是,当我尝试从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 and Jinja2 are my only requirements. tqdm 和 Jinja2 是我唯一的要求。 I tried specifying the versions, not specifying—error each way.我尝试指定版本,而不是指定——每种方式都出错。

It appears that it's trying to find tqdm and Jinja2 on the testpypi server and not finding them (because they're only available at regular pypi).它似乎试图在 testpypi 服务器上找到 tqdm 和 Jinja2 但没有找到它们(因为它们仅在常规 pypi 上可用)。 Uploading the package to the non-test server and running pip install worked.将包上传到非测试服务器并运行 pip install 工作。

What do I need to add to the setup.py file (below) to get it to find the requirements when uploaded to testpypi?我需要在 setup.py 文件(如下)中添加什么才能让它在上传到 testpypi 时找到要求?

Thanks!谢谢!

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)

Update更新

PyPI has upgraded its site. PyPI 已升级其网站。 According to the docs , the new advice is:根据文档,新建议是:

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

  • --index-url points to your package on TestPyPI. --index-url指向您在 TestPyPI 上的包。
  • --extra-index-url points to dependencies on PyPI. --extra-index-url指向对 PyPI 的依赖。
  • poirot is your package. poirot是你的包裹。

Out-dated过时的

Try pip install --extra-index-url https://testpypi.python.org/pypi poirot .尝试pip install --extra-index-url https://testpypi.python.org/pypi poirot

See also a reference post .另请参阅参考帖子

Trying in Jan 2021, the update in the accepted answer didn't work for me.在 2021 年 1 月尝试,已接受答案中的更新对我不起作用。 This worked:这有效:

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

Note that the first URL is test.pypi.org/pypi , and the second is pypi.org/simple .请注意,第一个 URL 是test.pypi.org/pypi ,第二个是pypi.org/simple

Their official page should be updated, its instruction shows:他们的官方页面应该更新,其说明显示:

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

which does not work.这是行不通的。

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

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