Can installin pip for python install dependencies aswell

+1 vote

I'm new to python packaging and distributing. I have a python app which I want to pip install, so I created a setup.py for it.

Now the setup.py has install_requires which alerts if a dependency is missing, but I'm wondering if I can/should provide a way to automatically install missing dependencies. Currently the app requires one self-developed shared package, and no external packages.

EDIT:

My setup.py:

from setuptools import setup

setup(
    name="TcpMonitor",
    version="1.0",
    packages=["tcpmonitor"],
    py_modules=["tcp_monitor"],
    install_requires=[
        "CommonPyLib",
    ],
    entry_points='''
        [console_scripts]
        tcp_monitor_gui=tcpmonitor:main
    '''
)

Pip install output:

Collecting CommonPyLib (from TcpMonitor==1.0)
  Could not find a version that satisfies the requirement CommonPyLib (from TcpMonitor==1.0) (from versions: )
No matching distribution found for CommonPyLib (from TcpMonitor==1.0)

Sep 26, 2018 in Python by bug_seeker
• 15,510 points
871 views

1 answer to this question.

0 votes

As long as the dependency is listed in the install_requires list, it will automatically check for that module and if not present it will install it, providing that the module can be installed from PyPi. If not (where that package cannot be found on PyPi) you get a Could not find a version that satisfies the requirement error.

I could not find any packages with this name on PyPi so you need to add the dependency to be installed on PyPi to be installed via pip, if you host your package elsewhere (GitHub for example) this may provide a solution: How can I make setuptools install a package that's not on PyPI?.

Running pip install commonpylib returns

Could not find a version that satisfies the requirement commonlib (from versions: ) No matching distribution found for commonpylib

So you do not have a setup script problem but a problem with finding the package on PyPi (which does not seem to exist), or at least Python does not know where you have hosted it.

The other option is to integrate that package with what you are distributing without making it a dependency (i.e. add it to the __init__.py file ect).

answered Sep 26, 2018 by Priyaj
• 58,020 points

Related Questions In Python

0 votes
1 answer

How to Install pip for python 3.7 on Ubuntu 18?

The command you're looking for is: python3.7 -m ...READ MORE

answered Nov 20, 2020 in Python by Gitika
• 65,770 points
9,597 views
0 votes
1 answer

Install pip in Python 3.4

Don't worry! Python already comes in default ...READ MORE

answered May 1, 2018 in Python by aayushi
• 750 points
3,419 views
0 votes
1 answer

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

answered Aug 20, 2018 in Python by charlie_brown
• 7,720 points
2,289 views
0 votes
2 answers

How can I install external binaries using portable python

0110100001000101001010101001011010100100111100101001 READ MORE

answered Jan 24, 2019 in Python by anonymous
2,193 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
0 votes
1 answer

How can I check for NaN in Python?

math.isnan() Checks if the float x is a ...READ MORE

answered Aug 16, 2018 in Python by Priyaj
• 58,020 points
24,219 views
0 votes
1 answer

Install PIP on Python 3.6

pip is bundled with Python > 3.4 On Unix-like ...READ MORE

answered Nov 12, 2018 in Python by Priyaj
• 58,020 points
1,291 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP