How to install python3 version of package via pip on Ubuntu?
Install a Python 3 package in a jiffy:
pip3 install package_name
Or flirt with a specific version infatuation:
pip3 install package_name==version_number
pip3
, the Columbia of Python 3 packages, is your go-to gal. But she can be fussy. To avoid sulking permission issues and version conflicts, invite her to a virtual environment.
System-wide installs might need sudo
to break through the bureaucracy:
sudo apt update
sudo apt install python3-pip
Or time-travel to Ubuntu 12.04:
sudo easy_install3 pip
Fast track to troubleshooting
Setting up the right workbench
Before you start, ensure you've got the Python package-building essentials:
sudo apt-get install python3-dev
This helps avoid frustrating compilation errors during installation of packages with C extensions.
The version tango
If pip3
gives you the silent treatment, look for versions like pip-3.2
or pip-3.3
on your system:
pip-3.X --version
Understandably, "X" might be a hopeless romantic still stuck with an old version. But it's no "ex"; replace X
with the version number. Consider therapy (updating) to avoid outdated versions.
Enlisting external allies
When the battle gets tough, get-pip.py
comes to the rescue:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
or
wget https://bootstrap.pypa.io/get-pip.py
Then call in the reinforcements:
sudo python3 get-pip.py # "I need a hero!" 🎵
This ensures Python 3 gets the latest pip refreshment.
Virtual sanity in an insane world
Hallucinating about a saner system? A virtual environment is just what the shrink ordered:
python3 -m venv chillpill
source chillpill/bin/activate # "Keep calm and carry on."
Now relax as you pip3 install
in the tranquil chillpill
.
Elevating your game: The make-it-or-break-it tactics
Riding the wave of modernity
The pip3 folks never sleep! Always sprint towards the latest Ubuntu release to catch the newest toys.
The globals-vs-virtauls debate
The lazy sudo pip3 install
might look like a short cut to global install, but it's a minefield of dependency conflicts. Play house with virtual environments in the safe confines of pyenv
or pipenv
.
Adding more arrows to your quiver
Sometimes, a package might decide to go rogue. Having weapons like build-essentials
could be a game changer:
sudo apt-get install build-essential # Suit up, it's judgement day!
Equip yourself with the trusty gcc
compiler and further tools to ace those daunting compilations.
Was this article helpful?