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
• 14,960 points
30 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,100 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
40 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,710 points
44 views
0 votes
2 answers

How can I install external binaries using portable python

0110100001000101001010101001011010100100111100101001 READ MORE

answered Jan 24 in Python by anonymous
71 views
0 votes
10 answers
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
19 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,100 points
1,707 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,100 points
28 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.