2

I have a test python project which requires specific versions of pandas, numpy and pyyaml. I have specified them in my setup.py file like this:

install_requires=[
    'numpy==1.21.5',
    'pandas==1.3.5',
    'PyYAML==6.0'
],

However, when installing the library with the command

 pip install -i https://test.pypi.org/simple/ dummydf

I would expect pip to automatically install those pinned versions. However, it does not do it. What would be the way of installing those dependencies?

EDIT: for example, if I install paramiko, I don't have to manually install any requirements.txt file. That's what I mean with my library.

EDIT2: this is what shows for me after trying to build the dist and wheel for the project having requirements.txt

(venv) PS C:\Users\u339990\learning_scripts\my_python_project\hola> pip install -i https://test.pypi.org/simple/ dummydf
Looking in indexes: https://test.pypi.org/simple/
Collecting dummydf
  Downloading https://test-files.pythonhosted.org/packages/a6/70/66df4bd4f0506745508a5a3ceb2fd72e2efdf26949d1bc6e6efc47819c9c/dummydf-0.0.6-py3-none-any.whl (6.3 kB)
  Downloading https://test-files.pythonhosted.org/packages/69/39/7a8a4757b2b198ea88478005d0ca6ff4f66e5d1544713ad327b76e7e8628/dummydf-0.0.5-py3-none-any.whl (6.3 kB)
  Downloading https://test-files.pythonhosted.org/packages/1b/0b/ae35d181a56c65699f25cd7b159706cac03c585530a1580df78c54d746ed/dummydf-0.0.4-py3-none-any.whl (6.3 kB)
  Downloading https://test-files.pythonhosted.org/packages/6a/0c/458d226ba99724a72db3275ddbc36278fe373c2dac4cb69463673ea630b2/dummydf-0.0.3-py3-none-any.whl (5.9 kB)
  Downloading https://test-files.pythonhosted.org/packages/12/78/5de1985bc5b2e5c72a383e9ee659e6fcac8cfc2e59c356c0c7561acd84fa/dummydf-0.0.2-py3-none-any.whl (5.9 kB)
  Downloading https://test-files.pythonhosted.org/packages/90/39/b00805590de570fb7aaaac46e991660b29660dd75052cb2507ab5cb08241/dummydf-0.0.1-py3-none-any.whl (5.8 kB)
ERROR: Cannot install dummydf==0.0.1, dummydf==0.0.2, dummydf==0.0.3, dummydf==0.0.4, dummydf==0.0.5 and dummydf==0.0.6 because these package versions have conflicting dependencies.

The conflict is caused by:
    dummydf 0.0.6 depends on numpy==1.21.5
    dummydf 0.0.5 depends on numpy==1.21.5
    dummydf 0.0.4 depends on numpy==1.21.5
    dummydf 0.0.3 depends on numpy==1.21.5
    dummydf 0.0.2 depends on numpy==1.21.5
    dummydf 0.0.1 depends on numpy==1.21.5

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
Javi Torre
  • 724
  • 8
  • 23
  • 2
    https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/ – Chris_Rands Dec 25 '21 at 12:18
  • 2
    https://stackoverflow.com/a/16624700/11724014 Is this answer your question? – Vincent Bénet Dec 25 '21 at 12:22
  • @Chris_Rands thanks. So, what I understood from the link is that install_requires should not contain pinned versions but is the only one that can be automatically processed by pip install. How could an end user just install my library without having to worry about manually installing the requirements.txt file? – Javi Torre Dec 25 '21 at 12:28
  • @VincentBénet not really, but I will read it carefully as it provides some additional insight to my question. – Javi Torre Dec 25 '21 at 12:29

1 Answers1

1

To use a requirements.txt file, specify it with the -r command line argument.

pip install -r requirements.txt
Silvio Mayolo
  • 62,821
  • 6
  • 74
  • 116
  • Please see my edit. What I'm trying to understand is if there is any way to avoid doing that for the end users. – Javi Torre Dec 25 '21 at 12:19