Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

Installing google-cloud-compute 1.5.0 and Cirq 1.0.0 simultaneously fails due to conflicting requirement

Open rht opened this issue 3 years ago • 4 comments

Description of the issue

I am trying to use google-cloud-compute 1.5.0 and Cirq 1.0.0 within the same virtualenv environment. But they can't be installed together without conflict.

ERROR: Cannot install -r requirements.txt (line 2), -r requirements.txt (line 5) and cirq because these package versions have conflicting dependencies.

The conflict is caused by:
    google-cloud-compute 1.5.0 depends on google-api-core[grpc]<3.0.0dev and >=2.8.0
    cirq-google 1.0.0 depends on google-api-core[grpc]<2.0.0dev and >=1.14.0

How to reproduce the issue

Using this requirements.txt

cirq==1.0.0
google-cloud-compute~=1.5.0

I do `pip install -r requirements.txt

Cirq version

1.0.0

rht avatar Oct 11 '22 03:10 rht

My current workaround is to first install cirq, and then in a separate pip install, install the requirements.txt. This will override the google-api-core version to be >2.0.0-dev. But this solution is not ideal.

rht avatar Oct 11 '22 04:10 rht

Are you using anything from cirq-google? If not, you can install cirq-core rather than cirq and avoid the dependency on google-api-core altogether. It's generally a good idea to install the specific cirq-* submodules that you need rather than the cirq metapackage itself, precisely for this reason that it reduces the number of dependencies and hence the possibility for version conflicts.

If you do need cirq-google, we can try extending the declared version range for google-api-core but we'll have to check that this works with generated client code that we're using.

maffoo avatar Oct 11 '22 14:10 maffoo

Yeah, I'm not using cirq-google actually. I wasn't aware that cirq is a meta package, and cirq-core is what one should install most of the time.

rht avatar Oct 11 '22 15:10 rht

I wasn't aware that cirq is a meta package, and cirq-core is what one should install most of the time.

This is probably something we should document better. Most of our tutorials and introductory materials still do pip install cirq for simplicity, but at the very least we should document the submodule structure and the fact that you can do pip install cirq-core to get just the core and then add other modules as needed.

maffoo avatar Oct 11 '22 17:10 maffoo

verification needed - is this still an issue at cirq==1.1.0 ?

If still a problem, we should update documentation to explain that only cirq-core should be installed to avoid version conflicts with vendor packages (cirq-google, cirq-inonq, etc.)

pavoljuhas avatar May 17 '23 17:05 pavoljuhas

On a fresh virtualenv:

ERROR: Cannot install -r requirements.txt (line 2) and cirq because these package versions have conflicting dependencies.

The conflict is caused by:
    cirq-google 1.1.0 depends on google-api-core[grpc]<2.0.0dev and >=1.14.0
    google-cloud-compute 1.5.2 depends on google-api-core[grpc]<3.0.0dev and >=2.9.0
    cirq-google 1.1.0 depends on google-api-core[grpc]<2.0.0dev and >=1.14.0
    google-cloud-compute 1.5.1 depends on google-api-core[grpc]<3.0.0dev and >=2.8.0
    cirq-google 1.1.0 depends on google-api-core[grpc]<2.0.0dev and >=1.14.0
    google-cloud-compute 1.5.0 depends on google-api-core[grpc]<3.0.0dev and >=2.8.0

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

rht avatar May 18 '23 07:05 rht

Closing - the requirements can be resolved for the latest google-cloud-compute 1.18.0 and cirq 1.3.0 or cirq 1.4.0.dev.

Verification

# requirements.txt

cirq~=1.0.dev
google-cloud-compute~=1.18.0

dependency resolution check for the last stable cirq 1.3.0 and the last dev release:

$ pip install uv
$ uv pip compile requirements.txt
... passing

$ uv pip compile --prerelease=allow requirements.txt
... passing

pavoljuhas avatar Apr 30 '24 19:04 pavoljuhas