Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install.sh: make sure pip2 is used on systems that have pip3 as its default pip installation #404

Closed
juanrubio opened this issue Dec 3, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@juanrubio
Copy link
Collaborator

commented Dec 3, 2017

As reported by @mkg20001 in #401, on systems where pip3 is the default pip installation, Tizonia's install script should detect it and make sure a functional pip2 installation exists and is used to install Tizonia's python dependencies:

Fixed it by running sudo pip2 install --upgrade pafy
Because the setup has used python3 pip instead of python2 pip
Should be fixed in the setup scirpt

@juanrubio juanrubio added the bug label Dec 3, 2017

@juanrubio juanrubio added this to the v0.11.0 milestone Dec 3, 2017

@juanrubio juanrubio self-assigned this Dec 3, 2017

@juanrubio juanrubio changed the title install.sh: make sure pip2 is used on systems that have pip3 aliased as pip install.sh: make sure pip2 is used on systems that have pip3 as its default pip installation Dec 3, 2017

@mkg20001

This comment has been minimized.

Copy link

commented Dec 4, 2017

I have written a script to detect pip2

Might be useful

#!/bin/bash

detectpip() {
  for p in pip pip2; do
    bin=$(which $p)
    if [ ! -z "$bin" ]; then
      bang=$(cat "$bin" | head -n 1)
      if [[ "$bang" == "#!"* ]]; then
        py=${bang/"#!"/}
        if [ ! -e "$py" ]; then
          echo "WARN: pip ($bin) has malformed bang!"
        else
          v=$("$py" --version 2>&1)
          if [[ "$v" == "Python 2"* ]]; then
            pip="$bin"
          fi
        fi
      else
        echo "WARN: pip ($bin) has malformed bang!"
      fi
    fi
  done
}

detectpip

if [ -z "$pip" ]; then
  echo "ERROR: Python 2 pip not found. Is it installed?"
else
  echo "pip=$pip"
fi
@juanrubio

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 5, 2017

Thanks!.

I've been looking into this a bit and definitely your script would be the most robust method of discovering a sane pip2 installation.

However, I've noticed that on debian/raspbian systems, it is pretty safe to assume that pip2 will always point to the python 2 version. It is only when using pip when things can go wrong, as in some cases, pip could be overwritten/shadowed with the python 3 version.

Some interesting discussion about these issues here: pypa/pip#3164

So I'm thinking I will simply directly use pip2 on install.sh, since this script is only meant to be used on debian/ubuntu/raspbian distros. If the user does not have a pip2 or has it pointing to a python 3 version, then well, he/she has a bigger problem than not being able to install tizonia :-)

@juanrubio juanrubio closed this in 11e863f Dec 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.