60

I'm trying to create my first python package. To not bungle the whole deal, I've been attempting to upload it to the testpypi servers. That seems to go fine (sdist creates and upload doesn't show any errors). However, when I try to install it to a new virtualenv from https://testpypi.python.org/pypi, it complains about my install requirements, e.g.:

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. 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). Uploading the package to the non-test server and running pip install worked.

What do I need to add to the setup.py file (below) to get it to find the requirements when uploaded to 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)
1
  • 1
    I'm having the same problem. Can you add the output from pip install --verbose --index-url https://testpypi.python.org/pypi/ poirot?
    – pylang
    Jan 1, 2016 at 18:40

2 Answers 2

79

Update

PyPI has upgraded its site. According to the docs, the new advice is:

python -m 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.
  • --extra-index-url points to dependencies on PyPI.
  • poirot is your package.

Caution: despite this recommendation from the official docs, using --extra-index-url can be unsafe in certain situations, particularly on private servers. See also A. Sottile's video demonstrating the risks related to option ordering and mixing public with private PyPI servers. Use with caution and assess your own risks.


Out-dated

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

See also a reference post.

4
  • 10
    For those in later years -> use https://test.pypi.org/simple/ instead. Mar 2, 2019 at 20:46
  • I tried this solution and faced another issue. There is another package on pypi, which has the same name as my package and the command install the other package from pypi instead of my package. Is it possible to install my own package on testpypi and the dependencies from pypi?
    – Qi Yin
    Apr 27, 2021 at 7:15
  • 1
    @QiYin, if there’s already a project on PyPI with the same name that you want to use for your project, that's a sign that you should change the name of your project. After all, usually one uses Test.PyPI as a step towards putting the project on PyPI. You won't be able to do that, with your current name, because that name is already taken on PyPI. Note that this doesn't mean you need to change the name of your module. That's distinct from the project name. May 28, 2022 at 15:56
  • Was facing the same issue and the solution in this answer resolved things for me -- my package was able to be installed through test.pypy.org and the dependences were pulled from pypi.org as expected, though I only used <package_name> for my package vs. the entire URL
    – alphazwest
    Jan 11 at 16:07
17

Trying in Jan 2021, the update in the accepted answer didn't work for me. 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.

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.

3
  • 1
    Okay, your answer seemed to work for me. But I'm not sure why it does and why it didn't before. I say this because the official page has not changed and still mentions the same command. There has to be a reason for this, right? Could you please give me some clarity as to what exactly your command and the one given in the official page does?
    – revmatcher
    Oct 3, 2022 at 14:40
  • I had similar problem, but my requirements was scipy==1.9. test.pypi has scipy with max version 0.1! After than it all worked soo well. I thinks its just dummy package :) Jan 4 at 14:38
  • This format was the one that finally worked for me.
    – alphazwest
    Jan 11 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.