Why is python setup.py saying invalid command 'bdist_wheel' on Travis CI?

My Python package has a setup.py which builds fine locally on Ubuntu Trusty and on a fresh Vagrant Ubuntu Trusty VM when I provision it like this:

    sudo apt-get install python python-dev --force-yes --assume-yes --fix-broken
    curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
    sudo -H pip install setuptools wheel virtualenv --upgrade

But when I do the same on a Travis CI Trusty Beta VM:

    - sudo apt-get install python python-dev --force-yes --assume-yes --fix-broken
    - curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
    - sudo -H pip install setuptools wheel virtualenv --upgrade

I get:

    python2.7 setup.py bdist_wheel
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
    error: invalid command 'bdist_wheel'

This Why can I not create a wheel in python? is related but note I am installing wheel and upgrading setuptools.

This problem is due to:

  • an old version of pip (6.1.1) being installed for Python 2.7
  • multiple copies of Python 2.7 installed on the Trusty Beta image
  • a different location for Python 2.7 being used for sudo

It's all a bit complicated and better explained here https://github.com/travis-ci/travis-ci/issues/4989.

My solution was to install with user travis instead of sudo:

    - pip2.7 install --upgrade --user travis pip setuptools wheel virtualenv

From: stackoverflow.com/q/34819221

Back to homepage or read more recommendations: