Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore pkg_resources.ContextualVersionConflict or ResolutionImpossible

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
like image 816
Ram Idavalapati Avatar asked Dec 20 '25 08:12

Ram Idavalapati


1 Answers

have you considered doing something like:

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.18.4,<3"  # Adjusted
    ],
    entry_points={"console_scripts": ["my_pack = my_pack:main"]},
)
like image 152
prhmma Avatar answered Dec 21 '25 21:12

prhmma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!