Using an extra python package index url with setup.py

If you’re the package maintainer, and you want to host one or more dependencies for your package somewhere other than PyPi, you can use the dependency_links option of setuptools in your distribution’s setup.py file. This allows you to provide an explicit location where your package can be located. For example: from setuptools import setup setup( … Read more

Optional dependencies in a pip requirements file

Instead of specifying optional dependencies in the same file as the hard requirements, you can create a optional-requirements.txt and a requirements.txt. To export your current environment’s packages into a text file, you can do this: pip freeze > requirements.txt If necessary, modify the contents of the requirements.txt to accurately represent your project’s dependencies. Then, to … Read more

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

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 … Read more

How to install PyPi packages using anaconda conda command

I will disagree with the accepted response and note that pip install [some-pypi-package] is often the best way to install PyPi packages in Conda environments. While the packages won’t be managed by the Conda package manager, they will still be managed by the Anaconda environment. It will download the correct version of the package for … Read more

How do I automatically install missing python modules? [duplicate]

Risking negative votes, I would like to suggest a quick hack. Please note that I’m completely on board with accepted answer that dependencies should be managed externally. But for situations where you absolutely need to hack something that acts like self contained, you can try something like below: import os try: import requests except ImportError: … Read more

Credentials in pip.conf for private PyPI

You could store credentials for Pip to use in ~/.netrc like this: machine pypi.example.com login johndoe password changeme Pip will use these credentials when accessing https://pypi.example.com but won’t log them. You must specify the index server separately (such as in pip.conf as in the question). Note that ~/.netrc must be owned by the user pip … Read more

How to upload new versions of project to PyPI with twine?

PyPI does not allow for the reuse of distribution filenames (project name + version number + distribution type). This ensures that a given distribution for a given release for a given project will always resolve to the same file, and cannot be surreptitiously changed one day by the projects maintainer or a malicious party (it … Read more