geekygeek
geekygeek

Reputation: 751

Could not find a version that matches protobuf?

I need to check my dependencies with this command:

pipreqs ./myPorjectFolder --savepath requirements.in --force && pip-compile

This command used to work just fine. However, I am now received this error:

INFO: Successfully saved requirements file in requirements.in
Could not find a version that matches protobuf<4.0.0dev,==4.21.1,>=3.15.0 (from -r requirements.in (line 4))
Tried: 2.0.3, 2.3.0, 2.4.1, 2.5.0, 2.6.0, 2.6.1, 3.0.0, 3.0.0, 3.1.0, 3.1.0.post1, 3.1.0.post1, 3.2.0, 3.2.0, 3.3.0, 3.4.0, 3.4.0, 3.5.0.post1, 3.5.0.post1, 3.5.1, 3.5.1, 3.5.2, 3.5.2, 3.5.2.post1, 3.5.2.post1, 3.6.0, 3.6.0, 3.6.1, 3.6.1, 3.7.0, 3.7.0, 3.7.1, 3.7.1, 3.8.0, 3.8.0, 3.9.0, 3.9.0, 3.9.1, 3.9.1, 3.9.2, 3.9.2, 3.10.0, 3.10.0, 3.11.0, 3.11.0, 3.11.1, 3.11.1, 3.11.2, 3.11.2, 3.11.3, 3.11.3, 3.12.2, 3.12.2, 3.12.4, 3.12.4, 3.13.0, 3.13.0, 3.14.0, 3.14.0, 3.15.0, 3.15.0, 3.15.1, 3.15.1, 3.15.2, 3.15.2, 3.15.3, 3.15.3, 3.15.4, 3.15.4, 3.15.5, 3.15.5, 3.15.6, 3.15.6, 3.15.7, 3.15.7, 3.15.8, 3.15.8, 3.16.0, 3.16.0, 3.17.0, 3.17.0, 3.17.1, 3.17.1, 3.17.2, 3.17.2, 3.17.3, 3.17.3, 3.17.3, 3.18.0, 3.18.0, 3.18.0, 3.18.1, 3.18.1, 3.18.1, 3.19.0, 3.19.0, 3.19.0, 3.19.1, 3.19.1, 3.19.1, 3.19.2, 3.19.2, 3.19.2, 3.19.3, 3.19.3, 3.19.3, 3.19.4, 3.19.4, 3.19.4, 3.20.0, 3.20.0, 3.20.0, 3.20.1, 3.20.1, 3.20.1, 4.21.0, 4.21.0, 4.21.0, 4.21.0, 4.21.1, 4.21.1, 4.21.1, 4.21.1
Skipped pre-versions: 2.0.0b0, 3.0.0a2, 3.0.0a3, 3.0.0b1, 3.0.0b1.post1, 3.0.0b1.post2, 3.0.0b2, 3.0.0b2, 3.0.0b2.post1, 3.0.0b2.post1, 3.0.0b2.post2, 3.0.0b2.post2, 3.0.0b3, 3.0.0b4, 3.0.0b4, 3.2.0rc1, 3.2.0rc1, 3.2.0rc1.post1, 3.2.0rc1.post1, 3.2.0rc2, 3.2.0rc2, 3.7.0rc2, 3.7.0rc2, 3.7.0rc3, 3.7.0rc3, 3.8.0rc1, 3.8.0rc1, 3.9.0rc1, 3.9.0rc1, 3.10.0rc1, 3.10.0rc1, 3.11.0rc1, 3.11.0rc1, 3.11.0rc2, 3.11.0rc2, 3.13.0rc3, 3.13.0rc3, 3.14.0rc1, 3.14.0rc1, 3.14.0rc2, 3.14.0rc2, 3.14.0rc3, 3.14.0rc3, 3.15.0rc1, 3.15.0rc1, 3.15.0rc2, 3.15.0rc2, 3.16.0rc1, 3.16.0rc1, 3.16.0rc2, 3.16.0rc2, 3.17.0rc1, 3.17.0rc1, 3.17.0rc2, 3.17.0rc2, 3.18.0rc1, 3.18.0rc1, 3.18.0rc1, 3.18.0rc2, 3.18.0rc2, 3.18.0rc2, 3.19.0rc1, 3.19.0rc1, 3.19.0rc1, 3.19.0rc2, 3.19.0rc2, 3.19.0rc2, 3.20.0rc1, 3.20.0rc1, 3.20.0rc1, 3.20.0rc2, 3.20.0rc2, 3.20.0rc2, 3.20.1rc1, 3.20.1rc1, 3.20.1rc1, 4.0.0rc1, 4.0.0rc1, 4.0.0rc2, 4.0.0rc2, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2
There are incompatible versions in the resolved dependencies:
  protobuf==4.21.1 (from -r requirements.in (line 4))
  protobuf<4.0.0dev,>=3.15.0 (from google-api-core==2.8.1->google_api_python_client==2.49.0->-r requirements.in (line 2)

The requirements.in file it is referencing contains the following:

filelock==3.7.0
google_api_python_client==2.49.0
google_auth_oauthlib==0.5.1
protobuf==4.21.1
scipy==1.8.1
sentry_sdk==1.5.12

I checked pypi and clearly, protobuf==4.21.1 is there.

Why is this problem happening?

Generally, I've had problems with protobuf.

If I am not mistaken, isn't the problem that pipreqs says I need 4.21.1 but the software requires it to be between 4.0.0 and 3.15.0? Obviously, that is an invalid condition.

How can I get pipreqs to require the correction version such as 3.20.1?

Upvotes: 1

Views: 6959

Answers (1)

geekygeek
geekygeek

Reputation: 751

It appears the package version condition is not possible.

The conditions are:

  • 3.15.0 < Version < 4.0.0 (from Gmail API)
  • Version == 4.21.1 (from pipreqs?)

I'm not certain why pipreqs is generating a requirements.in file that says protobuf==4.21.1 when the Gmail API requires something between 3.15.0 and 4.0.0.

I ended up manually replacing the protobuf==4.21.1 in the requirements.in file, and separated the pipreqs and pip-compile commands so that I could modify the intermediate requirements.in file before being passed into pip-compile, which is where the error was occurring.

os.system("pipreqs ./myProject --savepath requirements.in --force")
lines = None
with open('requirements.in', 'r') as FID: 
    lines = FID.readlines()
    for index,line in enumerate(lines ): 
        if 'protobuf' in line: 
            lines[index] = 'protobuf==3.20.1\n'

with open('requirements.in', 'w') as FID: 
    FID.writelines(lines)
    
os.system("pip-compile")

Upvotes: 1

Related Questions