'pip not installing entry_points as executables

I'm trying to create a package of my own. The package is very simple, it has one python module and one bash script. I wan both of them to be installed under /usr/local/bin so that they can be directly executed.

Here's my setup.py file:

from setuptools import setup

setup(
    name='deploy',
    .
    .
    .
    install_requires=['pyyaml', 'cot', 'jsonschema'],
    entry_points={
        'console_scripts': [
            'cloud_config = cloud_config:main',
        ],
    },
    scripts=['deploy.sh'],
)

Here's excerpt from output of pip install ...:

running install_scripts
    copying build/scripts-2.7/deploy.sh -> /usr/local/lib/python2.7.10/bin
    changing mode of /usr/local/lib/python2.7.10/bin/deploy.sh to 755
    Installing cloud_config script to /usr/local/lib/python2.7.10/bin

With this, I'm not able to invoke either the python or the bash script directly.

Any ideas?

Edit: I'm running the pip on Ubuntu 16.04.1 machine. Just tried to install the same package on a Ubuntu 14.04 machine and behavior is as expected. cloud_config.py and deploy.sh both get installed to /usr/local/bin and I can invoke both from anywhere on the system.



Solution 1:[1]

Two options I can think of, first,check that pip is pointing in the right place. So try:

which python

mine says:

/usr/bin/python

yours will be different, change the path accordingly to then make sure the PATH is properly set, so:

export PATH=/usr/bin/python:${PATH}

Reinstall pip and try again. Failing that, a workaround might be to not use pip in this instance and try:

python setup.py install

which will use your default python path (not pip) and should install to:

/usr/local/bin 

Solution 2:[2]

Try:

pip install --install-option="--prefix=$PREFIX_PATH" package_name

e.g.

pip install --install-option="--prefix=/usr/local/bin" pyFooBar

Solution 3:[3]

console_scripts does not work with old versions of pip. pip 10.0.1 is too old. pip 19.0.3 is sufficiently new.

Solution 4:[4]

I also found I could install a package and it appeared to be successful, but the entry_points scripts weren't in my PATH. Turned out that pip silently failed to install them.

Try running setup.py install directly. Doing that showed me access errors when trying to install the scripts into /usr/local/bin even though pip install -e . showed no errors. (See more about using -e.)

The solution to my problem was to use --prefix:

pip install --prefix ~/apps -e .

And ~/apps/bin is in my $PATH. To install to /usr/local/bin, you'd either have to change its permissions or run pip as root.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick H
Solution 2 alexisdevarennes
Solution 3 Edward Z. Yang
Solution 4 idbrii