pip finds conflicting depencecies
Problem description
I am running through trying to release my first package an I was doing testing on test.pypi,org by uploading my package via twine and then trying to install via pip. At this point I have uploaded several versions to fix bugs I found during testing. When I try to install the package from test.pypi.org via pip in a fresh virtual environment pip is unable to resolve the single dependency the package has pywin32. I am using a setup.cfg with the below options section declare the dependency
[options]
packages = find:
install_requires =
pywin32
I am trying to install the package via the following command
pip install --index-url https://test.pypi.org/simple winservicetools
Pip proceeds to download all available versions and indicates the versions have conflicting dependencies. I yanked several earlier versions of the packages where I had forgotten the install_requires line if those are present it will install those over the higher number versions.
I personally have been able to recreate this same issue on two different machines. I think any one should be able to recreate it by just trying the pip install command above on a Windows machine.
I feel like I have to be missing something simple. I tried specifying a version for pywin32 but that didn't help. What newbie detail am I missing?
I am using pip version 24.0 Python 3.12.2 Windows 10
Thanks for any help
Can you paste the full error message please?
The test PyPI is not meant to be used like this. Basically it is meant to upload your distributions (sdist and wheel), so that you can check how it will appear (descriptions, links, metadata, etc.) before uploading to real PyPI, and that's pretty much the end of it.
When you use pip's --index-url option, you instruct pip to use test PyPI exclusively, but test PyPI contains a bunch of random things (other people's test uploads) so there is huge uncertainty as to what pip will find, download, and install. Maybe it will not find what it needs, maybe it will find unsavory things.
@sinoroc ok yeah that makes sense. Like I said missing something simple. It is trying to look on test.pypi.org for pywin32 and can't find it because I have told pip that is only index to look at. Yeah I am lucky there wasn't any unsavory pywin32 package up there.
I will at this juncture point out the the guide does say test pip with test PyPi
https://packaging.python.org/en/latest/guides/using-testpypi/
An then right below it is has the command that would have saved me making this issue that has the --extra-url argument pointing to the real PyPi.org.
So on balance I don't know if you guys want to revise that incase unsavory packages are on test.pypi.org or at least maybe put a warning.
Thanks for the help
I was able to test by adding the --extra-index-url and this did indeed solve the problem.
@jeanas I still wanted to post the full error message as you requested because the error that occurs does not make it obvious that it cannot find the pywin32 dependency. The error definitely was leading me down the path of a dependency conflict rather than pip not being able to find the dependency.
pip install --index-url https://test.pypi.org/simple winservicetools --no-cache
Looking in indexes: https://test.pypi.org/simple
Collecting winservicetools
Downloading https://test-files.pythonhosted.org/packages/cc/59/0ddfca597ce8f3960f032fa45f87364503d75805f05d8a8e279fb4df210f/winservicetools-0.7.0-py3-none-any.whl.metadata (10 kB)
INFO: pip is looking at multiple versions of winservicetools to determine which version is compatible with other requirements. This could take a while.
Downloading https://test-files.pythonhosted.org/packages/72/1e/4c13671705ef3af385362b172b71094bb6ab178a7c99e475de6ba4a2ac30/winservicetools-0.6.0-py3-none-any.whl.metadata (10 kB)
Downloading https://test-files.pythonhosted.org/packages/59/47/d93e58d45031d7ffa4991dedd8c171c61462db380f7e3ba73adefd2dfb3a/winservicetools-0.5.0-py3-none-any.whl.metadata (10 kB)
Downloading https://test-files.pythonhosted.org/packages/1b/81/e028c44c1cf1127d8b52d1c1c729be9418bcbba77f9d35eed2b9d8eed53b/winservicetools-0.4.0-py3-none-any.whl.metadata (10 kB)
ERROR: Cannot install winservicetools==0.4.0, winservicetools==0.5.0, winservicetools==0.6.0 and winservicetools==0.7.0 because these package versions have conflicting dependencies.
The conflict is caused by:
winservicetools 0.7.0 depends on pywin32>=210
winservicetools 0.6.0 depends on pywin32
winservicetools 0.5.0 depends on pywin32
winservicetools 0.4.0 depends on pywin32
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/topics/dependency-resolution/#dealing-with-dependency-conflicts
Maybe the message can be improve for this use case. Otherwise you can consider this question resolved from my point of view thanks again for the help.
I will at this juncture point out the the guide does say test pip with test PyPi
https://packaging.python.org/en/latest/guides/using-testpypi/
An then right below it is has the command that would have saved me making this issue that has the --extra-url argument pointing to the real PyPi.org.
So on balance I don't know if you guys want to revise that incase unsavory packages are on test.pypi.org or at least maybe put a warning.
Good point. Do you mind opening a bug ticket for this on the repository for the guide itself?
https://github.com/pypa/packaging.python.org/issues
That would be great if you could do that, but if possible check beforehand in case it has already been reported.