簡體   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