How to install pip in CentOS 7? - pip

CentOS 7 EPEL now includes Python 3.4: yum install python34
However, when I try that, even though Python 3.4 installs successfully, it doesn't appear to install pip. Which is weird, because pip should be included by default with Python 3.4. which pip3 doesn't find anything, nor does which pip.
How do I access pip from the Python 3.4 package in CentOS 7 EPEL release?

The easiest way I've found to install pip3 (for python3.x packages) on CentOS 7 is:
$ sudo yum install python34-setuptools
$ sudo easy_install-3.4 pip
You'll need to have the EPEL repository enabled before hand, of course.
You should now be able to run commands like the following to install packages for python3.x:
$ pip3 install foo

curl https://bootstrap.pypa.io/get-pip.py | python3.4
Or if you don't have curl for some reason:
wget https://bootstrap.pypa.io/get-pip.py
python3.4 get-pip.py
After this you should be able to run
$ pip3

The CentOS 7 yum package for python34 does include the ensurepip module, but for some reason is missing the setuptools and pip files that should be a part of that module. To fix, download the latest wheels from PyPI into the module's _bundled directory (/lib64/python3.4/ensurepip/_bundled/):
setuptools-18.4-py2.py3-none-any.whl
pip-7.1.2-py2.py3-none-any.whl
then edit __init__.py to match the downloaded versions:
_SETUPTOOLS_VERSION = "18.4"
_PIP_VERSION = "7.1.2"
after which python3.4 -m ensurepip works as intended. Ensurepip is invoked automatically every time you create a virtual environment, for example:
pyvenv-3.4 py3
source py3/bin/activate
Hopefully RH will fix the broken Python3.4 yum package so that manual patching isn't needed.

Update: The python34 bug mentioned below has finally been fixed. It is a perfectly fine choice now.
Rather than using broken EPEL python34 packages, you can enable the IUS repo and have it work properly.
pip inside virtual environments
The main python34u and python35u IUS packages include the pyvenv tool (/usr/bin/pyvenv-3.4 or /usr/bin/pyvenv-3.5) that includes bundled wheels of pip and setuptools for bootstrapping virtual environments.
global pip
The python34u-pip and python35u-pip IUS packages include /usr/bin/pip3.4 and /usr/bin/pip3.5 respectively. These work just fine to install packages to the system site-packages directory.

yum install python34-pip
pip3.4 install foo
You will likely need the EPEL repositories installed:
yum install -y epel-release

Update 2019
I tried easy_install at first but it doesn't install packages in a clean and intuitive way. Also when it comes time to remove packages it left a lot of artifacts that needed to be cleaned up.
sudo yum install epel-release
sudo yum install python34-pip
pip install package
Was the solution that worked for me, it installs "pip3" as pip on the system. It also uses standard rpm structure so it clean in its removal. I am not sure what process you would need to take if you want both python2 and python3 package manager on your system.

Below are the steps I followed to install python34 and pip
yum update -y
yum -y install yum-utils
yum -y groupinstall development
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum makecache
yum -y install python34u python34u-pip
python3.6 -v
echo "alias python=/usr/bin/python3.4" >> ~/.bash_profile
source ~/.bash_profile
pip3 install --upgrade pip
# if yum install python34u-pip doesnt work, try
curl https://bootstrap.pypa.io/get-pip.py | python

There is a easy way of doing this by just using easy_install (A Setuptools to package python librarie).
Assumption.
Before doing this check whether you have python installed into your Centos machine (at least 2.x).
Steps to install pip.
So lets do install easy_install,
sudo yum install python-setuptools python-setuptools-devel
Now lets do pip with easy_install,
sudo easy_install pip
That's Great. Now you have pip :)

Figure out what version of python3 you have installed:
yum search pip
and then install the best match. Use reqoquery to find name of resulting pip3.e.g
repoquery -l python36u-pip
tells me to use pip3.6 instead of pip3

On CentOS 7, the pip version is pip3.4 and is located here:
/usr/local/bin/pip3.4

Related

How can I Install pip3 with python on HDP3.0.1?

I've tried a few ways to install python3-pip on Hortonworks Sandbox HDP_3.0.1 but no success.
Could any one guide on how to achieve that correctly
Here's final answer for that:-
Become a root user first
yum update
you may found yum update failed because of some unavailble package you may skip that with
yum-config-manager --save --setopt=<package_name>.skip_if_unavailable=true
remove installed python package which has no available pip
yum remove python36u
install new one which has pip3 package available with it
yum install python3

System does not update Ansible on CentOS 8

I try to install ansible-core, which version is 2.12. I am installing this as per the documentation.
$ yum install epel-release
$ yum install ansible
But, the system keeps installing version 2.9.27.
It really makes me annoying because I've already had experience of installing ansible-core before and it worked. Anyway, I tried to reinstall ansible on the other CentOS 8 servers with the same installation process as I did before.
Please let me know how to install latest version or specific version of Ansible.
You can check the newest version of packages on this site: https://pkgs.org/search/?q=ansible.
At this point, the newest ansible package version is 2.9.27. So, you need to wait until they release a new version or consider compiling this package from the source yourself.
try
sudo yum install ansible-2.12.1
as in
sudo yum install <package_name>-<version_info>
hope this will work
But, the system keeps installing version 2.9.27.
You're installing Ansible from a repository. This means someone has packaged a certain version of Ansible.
You're OS is EL 8-like, the note on the website describes:
Since Ansible 2.10 for RHEL is not available at this time, continue to use Ansible 2.9.
how to install latest version or specific version of ansible
When installing python packages, you should not use the package manager of the system, but rather Pip. So, as part of the answer which is already been given in the comments, you should install Ansible via pip.
$ dnf install epel-release -y ; dnf install python3-pip -y
$ python3 -m pip install ansible
You can update to the latest version with:
$ python3 -m pip install ansible --upgrade
Install a specific version with:
$ python3 -m pip install ansible==5.0.1
Ensure to install python modules the same way you install Ansible.
$ python3 -m pip install yamllint

Python 3.6: how to install rubberband?

I want to use this function, and I'm trying to install rubberband using pip as the following: pip install rubberband
But, it raises the following error: "Failed building wheel for rubberband"
And I can't use Python 3.5 in my project. So, how to install rubberband?
P.S. My OS is Windows 10, and I have python 3.6 on it.
The docs you pointed to are the docs for the project pyrubberband, not rubberband. So install it with pip install pyrubberband.
As for rubberband: you probably need a C/C++ compiler to install it.
Upd. pyrubberband is a Python wrapper for rubberband. You need to install it, see https://breakfastquay.com/rubberband/index.html
To make a long story short, this is how I installed the rubberband python package.
apt update
apt-get install libsndfile-dev
apt-get install librubberband-dev
python3 -m pip install numpy (required for rubberband)
Note that the -dev postfix is required to get the header files that are later required for the python rubberband package to be able to compile the package.
Later, pip install rubberband failed on transform is not a member of std.
To solve that, I did the following:
python3 -m pip download rubberband
tar -xf rubberband-1.0.2.tar.gz
edit rubberband-1.0.2/src/numpy.cpp - add #include <algorithm> at the top of the file.
cd rubberband-1.0.2 and then run python3 -m pip install . or better yet python setup.py bdist_wheel --universal to create a whl file to add to your docker dependencies.
If you ran through this and using macOS, brew for everything works
$ brew install rubberband
Works like charm https://formulae.brew.sh/formula/rubberband
Install "rubberband-cli" Package on Ubuntu:
sudo apt-get update -y
sudo apt-get install -y rubberband-cli

How to uninstall Airflow?

I am a newbie to Airflow. i have some trouble to remove Airflow v1.10.3 ,i am using pip3 version 8.1.1 on Ubuntu 16.04.
I already tried to remove pip with sudo apt-get remove python3-pip
and sudo apt-get remove pip3 and all his dependencies.
and tried to remove all libraries related with Python.
But i stil have Airflow and his commands down in terminal.
If you are not able to uninstall with
pip uninstall airflow
Maybe the reason is for the latest versions of Airflow this command will work
pip uninstall apache-airflow
Credits to This Answer.
The command apt-get remove pip doesn't remove pip-installed libraries.To uninstall pip-installed libraries you need to install pip back and then uninstall the libraries using pip:
sudo apt install pip # or pip3
pip uninstall airflow
or
pip3 uninstall airflow
depending on what python version you use.

How do I install pip modules on google compute engine?

I am trying to run some python script using ssh to log into the google compute engine but all the installed pip modules are not found as I do not have permission to the .cache/pip folder in my user is there a correct way to do this?
You should be running this with the root user.
Also, if you need pip inside your GCP Instance, you can use the following commands:
sudo curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py
[Source]
Use:
sudo apt-get install python3-pip
sudo runs this command as an administrator
apt-get is the standard package manager used on Debian Linux distributions
python3-pip is the package name for pip3
Once installed, you can install PIP modules with:
pip3 install MODULE_NAME
for example:
pip3 install tensorflow
I'm not entirely sure there is one correct way to do this, but an easy way would be to use the conda python package manager.
The lighter version of it is miniconda. You can get a minimal python installation with pip preinstalled, and virtual environments capability if you need. Assuming you are running on linux and want python 3, you'll have to run
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
and then install conda with
bash Miniconda3-latest-Linux-x86_64.sh
At the end of this process you should have a minimal python installation (that includes pip) and you'll be able to install packages with pip as you are used to.
You might want to install some basic libraries first -
sudo apt-get install bzip2 libxml2-dev
Then install miniconda as given by #teoguso and restart your shell
source ~/.bashrc
You can then use conda or pip to install your packages

Resources