Python PIP
Created: 2018-01-02 13:22:24 -0800 Modified: 2018-10-28 18:55:41 -0700
Basics
Section titled Basics- Install pip itself:
- Python 2.x:
sudo apt-get install python-pip
- Python 3.x:
sudo apt-get install python3-pip
- Either way, enter the Python shell by typing “python” or “python3” accordingly and type help(‘modules’) to see if you have “ensurepip”. If you do, you should have everything installed correctly.
- Python 2.x:
- Install with pip:
pip install ansible --user
- Uninstall with pip:
pip uninstall ansible
- Consider uninstalling using “sudo” if you messed up the install and installed as sudo
Background (reference)
Section titled Background (reference)This now comes with Python 3.4. I have mine at “C:Python34Scriptspip.exe”.
Installations go to libsite-packages, e.g. C:Python34Libsite-packagesmycli. However, you run them from C:Python34Scripts directly, so when I installed mycli, it ended up as a .exe in Scripts.
Troubleshooting
Section titled TroubleshootingPython pip install gives “Command ”python setup.py egg_info“ failed with error code 1”
Section titled Python pip install gives “Command ”python setup.py egg_info“ failed with error code 1”If that doesn’t work, just use easy_install which is right next to pip or maybe elevate and try again.
No module named packaging.version
Section titled No module named packaging.versionHere’s an example of the error
adam@debian1:~/.local/lib/python2.7$ pip uninstall
Traceback (most recent call last):
File “/usr/bin/pip”, line 5, in <module>
from pkg_resources import load_entry_point
File “/home/adam/.local/lib/python2.7/site-packages/pkg_resources/init.py”, line 70, in <module>
import packaging.version
ImportError: No module named packaging.version
To fix this, I followed this guidance (reference):
mv ~/.local/lib/python2.7/site-packages/pk_resources ~/.local/lib/python2.7/site-packages/pk_resources_bkp
Then I reran the command.