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,350 points
58 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
• 56,900 points

Related Questions In Python

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
86 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
93 views
0 votes
2 answers

How can I install external binaries using portable python

0110100001000101001010101001011010100100111100101001 READ MORE

answered Jan 24 in Python by anonymous
153 views
0 votes
11 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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 330 views
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
• 56,900 points
8,618 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
• 56,900 points
71 views