Main Menu

search

You are here

Python pip

last updated: 2022-09-26]
go to: Python home page
-----

  • pip is Package Installer for Python

  • Check to see if you already have it installed with:
    $ python3 -m pip --version
    Currently:
      Dell-4600 returns pip 20.0.2
      rPi-02 (SD-16) has pip 18.1

  • If it's not installed, install it with:
      (Note: I tried lots of suggestions from online that didn't work, however this method worked on my Dell-4600:)

    $ sudo apt-get install software-properties-common
    $ sudo apt-add-repository universe
    $ sudo apt-get update
    $ sudo apt-get install python3-pip

  • When I did:
      $ pip --version
      Error message said it was not installed, but I could install it with:
      $ sudo apt install python3-pip
      I did so, and it successfully installed v. 22.0 2 (for python 3.10)

    -------------------------------------------------

  • Install module/library with pip:
    • as always before installing new software:
      $ sudo apt update
      $ sudo apt upgrade
    • $ sudo apt install pip [module/libraryName]
      $ sudo apt -y install python3-rpi.gpio
    • Or, if pip is installed:
      $ pip install RPi.GPIO

  • However:
    • even though pip install RPi.GPIO said it was successful,
      program would not compile, and dpkg said in fact NOT installed.
    • from some forum:
        The problem on Linux is that pip install ... drops scripts into ~/.local/bin and this is not on the default Debian/Ubuntu $PATH.
        Here's a GitHub issue going into more detail: https://github.com/pypa/pip/issues/3813
        To fix, just add ~/.local/bin to your $PATH, for example by adding the following line to your .bashrc file:
          $ export PATH="$HOME/.local/bin:$PATH"

        After that, restart your shell and things should work as expected.

    • On my Linux Mint 21 tower,
      pip install RPi.GPIO put it into:
        /usr/local/lib/python3.10/dist-packages


      Also had trouble finding .bashrc file:

        found bash.bashrc in /etc


      Another forum post said:

        You use ~/.bashrc just the same as in Ubuntu. By default there is no file (because it would be empty?) so you have to create it first.

      Another post said there was (and I found) a copy of .bashrc in /etc/skel folder

        this file seems the same as bash.bashrc

      Another post said:

        inux

        Open the .bashrc file in your home directory (for example, /home/your-user-name/.bashrc) in a text editor.
        Add export PATH="your-dir:$PATH" to the last line of the file, where your-dir is the directory you want to add.
        Save the .bashrc file.
        Restart your terminal.

.

.

.

eof