13

I have built a python module which installs kwikapi==0.4.5 and requests==2.22.0. But kwikapi has requests==2.18.4.

Now when I install and run my package, I am getting error pkg_resources.ContextualVersionConflict: (requests 2.22.0 (/tmp/test_vir3.7/lib/python3.7/site-packages), Requirement.parse('requests==2.18.4'), {'kwikapi'}).

Now if I install requests==2.18.4(pip install requests==2.18.4) and run then the error is pkg_resources.DistributionNotFound: The 'requests==2.22.0' distribution was not found and is required by my-pack.

I can use 2.18.4 instead of 2.22.0 requests to solve this. But this problem again comes if I have same module with different versions in both requests and in kwikapi.

Is there a way to ignore/solve this error?

setup/reproduce

Module structure

.
├── my_pack
│   └── __init__.py
└── setup.py

setup.py

from setuptools import setup, find_packages

version = "0.0.1"
setup(
    name="my_pack",
    packages=find_packages("."),
    package_dir={"my_pack": "my_pack"},
    include_package_data=True,
    install_requires=[
        "kwikapi==0.4.5",
        "requests==2.22.0"
    ],
    entry_points={"console_scripts": ["my_pack = my_pack:main"]},
)

__init__.py

def main():
    print("Hey! I ran")

Create python virtual environment and activate

$ python3.7 -m venv vir
$ source vir/bin/activate

install

# Go to setup.py file location and do
$ pip install .

Run

$ my_pack
Ram Idavalapati
  • 666
  • 1
  • 10
  • 22
  • https://stackoverflow.com/q/60084441/7976758 In short: you should make your dependencies agree on using transitive subdependencies. – phd Feb 06 '20 at 07:10
  • 2
    The above answer is not sufficient. I have a version of torchvision (0.11.2+cu102) and a version of torch (1.11.0a0+git786f946) which work fine together. I can't use my entry point because of this issue. Instead I have to invoke everything via `python -m `. Is there any way to bypass this overzealous check or downgrade it to a warning? – Erotemic Jan 17 '22 at 17:24

0 Answers0