How to install pip specifically for Python3 on CentOS 7? - python

CentOS 7 already has Python2.7.5 stock installed. I am doing an online course that requires Python3.x installed. So these are the following steps i took to install Python3.7.3.rc1 :
$cd /usr/src
$sudo wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3rc1.tgz
$sudo tar xzf Python-3.7.3rc1.tgz
$cd Python-3.7.3rc1
$sudo ./configure --enable-optimizations
$sudo make altinstall
$sudo rm /usr/src/Python-3.7.3rc1.tgz
$python3.7 --version
Python 3.7.3rc1
I followed these steps religiously from this link : https://tecadmin.net/install-python-3-7-on-centos/
During my course i was required to install pyperclip using pip.
So i did :
$python3.7 -m pip install pyperclip
/usr/local/bin/python3.7: No module named pip
Please suggest a method to install pip for Python3.7.3rc1.

You should have taken the default available python3, that is the python3.6 package in centos7
that would have been easier to setup rather than compile an unsupported version.
Suggest you install the supported python3 package in centos
Try doing yum install python36 from repository
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
Update yum package
sudo yum update
Install python36 along with pip
sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
Below steps are for python3.7,
suggest avoiding unsupported packages.
Alternate Steps for pip setup for Centos
You need to install pip for python3.7 series
Step 1: First install the EPEL Repository
sudo yum install epel-release
Step 2: Installing pip
python37 -m pip
Step 3: Verify if pip was installed properly
pip --version
If the command not found error shows up, try
python37 -m ensurepip

I also as you said "followed these steps religiously from this link: https://tecadmin.net/install-python-3-7-on-centos/."
It was not an option for me to install python3.6, as I explicitly needed 3.7.
I was able to install using the following procedure:
# AFAIK, libffi-devel solved the "ModuleNotFoundError: No module named '_ctypes'" I had when I tried installing without it.
yum install libffi-devel
cd /usr/src
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar xzf Python-3.7.5.tgz
cd Python-3.7.5
./configure --enable-optimizations
make install # Or: make altinstall
python3 -V
pip3 --version
rm -f /usr/src/Python-3.7.5.tgz
What I changed from the referenced article is the version (3.7.5 instead of 3.7.4) and in addition installed "libffi-devel". It could be that this one would have solved on 3.7.4 as well.

For CentOS 6 and 7 you can run this:
sudo yum install python37-setuptools
sudo easy_install-3.7 pip
Edit: You should then be able to install using pip3 install <package>

Related

Creating a docker container that runs Ubuntu with Python 3.6+ and Pip

I'm trying to install Python 3.6 or above with pip in an docker container that runs Ubuntu. I've tried quite a few things with no success
FROM ubuntu:18.04
RUN apt update
RUN apt install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa
RUN ln -s /usr/bin/pip3 /usr/bin/pip
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN apt install python3.8 -y
RUN apt install pip
RUN pip install auto-sklearn
RUN pip install pandas
ADD test.py /
CMD [ "python", "./test.py" ]
This returns "Unable to locate package pip." I tried removing "apt install pip" incase Python 3.8 comes with it, but it gives me the error: "pip: not found."
FROM ubuntu:18.04
RUN apt install software-properties-common -y
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update
RUN install python3-pip
RUN pip install auto-sklearn
RUN pip install pandas
ADD test.py /
CMD [ "python", "./test.py" ]
This installs pip, but auto-sklearn requires Python version 3.6 or higher and this installs a lower version. Auto-sklearn requires Linux as well which is why I'm using "FROM ubuntu" rather than "FROM python" cause "FROM python" seems to build a container on whatever native OS is running on the computer building the container, which for me is Windows.
I see two consecutive issues here, so let's address them accordingly:
Issue 1: missing pip in the Ubuntu image
This returns "Unable to locate package pip." I tried removing "apt install pip" incase Python 3.8 comes with it, but it gives me the error: "pip: not found."
That's right. If you inspect the contents of the /usr/bin directory of the pulled image, you will notice that there is no pip or pip3 there. So RUN ln -s /usr/bin/pip3 /usr/bin/pip line in your Dockerfile does nothing. Even when python3.6 gets installed in the container (after calling apt install software-properties-common -y), you do not get pip with it.
Solution: install pip
The following commands can be used to install python3.6 binary and the corresponding pip:
RUN apt-get update
RUN apt-get install python3-pip
This installs both python3.6 and pip3 in the /usr/bin directory of your ubuntu:18/04 container.
Issue 2: auto-sklearn requires python >= 3.7
Even if you manage to get both python3.6 and pip for python3.6, installation of auto-sklearn might still fail with the following error:
RuntimeError: Python version >= 3.7 required.
This is because some of the dependencies (e.g. ConfigSpace package) require python version >= 3.7.
Solution:
This answer explains how to install pip for python3.8 on Ubuntu: https://stackoverflow.com/a/63207387/15043192
You can follow it or get both pip and python3.8 installed using the following sequence:
Install python3.8:
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update
RUN apt install python3.8
Install python3.6 and pip for python3.6
RUN apt install python3-pip
Now if you execute python3.6 -m pip --version in the container, you would get something like (the version of pip might be different):
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
Install pip for python3.8
Note: here we use previously installed pip for python3.6 to install pip for python3.8. Do not ask me why :-)
RUN python3.8 -m pip install pip --upgrade
Install auto-sklearn
RUN python3.8 -m pip install auto-sklearn
Note: the command above might also install pandas package among other dependencies of auto-sklearn.
Create a symbolic link to python3.8
This would change the default
RUN ln -s /usr/bin/python3.8 /usr/bin/python
Now if you execute python -m pip --version in the container, you would get something like (the version of pip might be different):
pip 21.2.4 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Grand finale:
In the end, your Dockerfile should look like this:
FROM ubuntu:18.04
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt update
RUN apt install python3.8
RUN apt install python3-pip
RUN python3.8 -m pip install auto-sklearn
RUN python3.8 -m pip install pandas
RUN ln -s /usr/bin/python3.8 /usr/bin/python
ADD test.py /
CMD [ "python", "./test.py" ]
NB
To avoid messing around with different versions of python and pip, you might want to have a look into virtual environments.

How do I install pip for python 3.8 on Ubuntu without changing any defaults?

I'm trying to install pip for Python 3.8 on an Ubuntu 18.04 LTS.
I know this has been asked way too many times. But those questions do not concern keeping Ubuntu's defaults specifically. And the answers on those questions either don't work or go on to suggest something so drastic that it would break the system - e.g. change default python3 version from 3.6 to 3.8. You SHOULDN'T!
So far, I've been able to install python3.8 successfully using the PPA - ppa:deadsnakes/ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8
Changed python command from python2 to python3.8 using update-alternatives:
update-alternatives --remove python /usr/bin/python2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 10
Now, I get python 3.8 when I run python --version:
Python 3.8.5
The problem is, I still can't install pip for Python 3.8.
If I try to install python3-pip, it installs pip for Python 3.6 since python3 still points to python3.6.9, and I intend to keep it that way.
Try installing python-pip, and it will install pip for Python 2.7.
Also there's no such package as python3.8-pip, so I can't install it like:
sudo apt install python3.8-pip
Output:
E: Unable to locate package python3.8-pip
E: Couldn't find any package by glob 'python3.8-pip'
E: Couldn't find any package by regex 'python3.8-pip'
What can I do to install pip for Python 3.8 on an Ubuntu 18.04?
While we can use pip directly as a Python module (the recommended way):
python -m pip --version
This is how I installed it (so it can be called directly):
Firstly, make sure that command pip is available and it isn't being used by pip for Python 2.7
sudo apt remove python-pip
Now if you write pip in the Terminal, you'll get that nothing is installed there:
pip --version
Output:
Command 'pip' not found, but can be installed with:
sudo apt install python-pip
Install python3.8 and setup up correct version on python command using update-alternatives (as done in the question).
Make sure, you have python3-pip installed:
(This won't work without python3-pip. Although this will install pip 9.0.1 from python 3.6, we'll need it.)
sudo apt install python3-pip
This will install pip 9.0.1 as pip3:
pip3 --version
Output:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
Now, to install pip for Python 3.8, I used pip by calling it as a python module (ironic!):
python -m pip install pip
Output:
Collecting pip
  Downloading https://files.pythonhosted.org/packages/36/74/38c2410d688ac7b48afa07d413674afc1f903c1c1f854de51dc8eb2367a5/pip-20.2-py2.py3-none-any.whl (1.5MB)
  100% |████████████████████████████████| 1.5MB 288kB/s
Installing collected packages: pip
Successfully installed pip-20.2
It looks like, when I called pip (which was installed for Python 3.6, BTW) as a module of Python 3.8, and installed pip, it actually worked.
Now, make sure your ~/.local/bin directory is set in PATH environment variable:
Open ~/.bashrc using your favourite editor (if you're using zsh, replace .bashrc with .zshrc)
nano ~/.bashrc
And paste the following at the end of the file
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
Finally, source your .bashrc (or restart the Terminal window):
source ~/.bashrc
Now if you try running pip directly it'll give you the correct version:
pip --version
Output:
pip 20.2 from /home/qumber/.local/lib/python3.8/site-packages/pip (python 3.8)
Sweet!
As suggested in official documentation you can try with get-pip.py.
wget https://bootstrap.pypa.io/get-pip.py
python3.8 get-pip.py
This will install pip as pip3.8
Another solution would be to install the pip that is in apt. sudo apt install python3-pip. The version of the pip that it installs is for all versions of Python not only for version 3.6 once installed you just need to update the pip with the command python3.8 -m pip install pip and he will be install the latest version of pip for Python.
I would not advise you to remove Python2 because it is an important module for the system you should just create a permanent "alias" in .bashrc for Python3 I did like this alias python="python3.8.
# install py3.8 and dependencies for the pip3 bootstrap script
add-apt-repository -y ppa:deadsnakes/ppa && \
apt install -y python3.8 python3.8-distutils
# download and run the pip3 bootstrap script
cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && \
python3.8 /tmp/get-pip.py
# use pip py3.8 module to install python packages
python3.8 -m pip install numpy pandas
Install python v3.8 as python
RUN apt update --fix-missing && \
apt install python3.8 -y && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.8 10
Install pip for python 3.8
RUN apt install python3-pip -y && \
python -m pip install --upgrade pip
I did this a couple days ago and I struggled a lot with it but I finally got it working, so I wrote up what I did as a blog post.
In the end I think I may have done mostly the same things as the above answer, but if you got lost following it, maybe my screenshots etc will help.
Here's the tl;dr of the process I did:
Uninstall python3-pip & python-pip using apt
Remove the old pip files from /usr/local/bin
Reinstall python3-pip using apt
Add $HOME/.local/bin to your $PATH (also restart your shell to make sure you did this right)
On ubuntu server
sudo apt install python -y
For more information check this blog here.
https://teckresolve.com/install-python-packages-using-pip/

Unable to install python-pip module [duplicate]

I am trying to install mininet-wifi. After downloading it, I have been using the following command to install it:
sudo util/install.sh -Wlnfv
However, I keep getting the error:
E: Unable to locate package python-pip
I have tried multiple times to download python-pip. I know mininet-wifi utilizes python 2 instead of python 3. I have tried to download python-pip using the command:
sudo apt-get install python-pip
But that leads to the same error:
E: Unable to locate package python-pip
Pip for Python 2 is not included in the Ubuntu 20.04 repositories. You need to install pip for Python 2 using the get-pip.py script.
1. Start by enabling the universe repository:
sudo add-apt-repository universe
2. Update the packages index and install Python 2:
sudo apt update
sudo apt install python2
3. Use curl to download the get-pip.py script:
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
4. Once the repository is enabled, run the script as sudo user with python2 to install pip :
sudo python2 get-pip.py
If an error occurs, as a fallback, the specific 2.7 version of get-pip.py can be used:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
Pip will be installed globally. If you want to install it only for your user, run the command without sudo. The script will also install setuptools and wheel, which allow you to install source distributions
Verify the installation by printing the pip version number:
pip2 --version
The output will look something like this:
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Since Python 2 is past its end-of-life, few packages for Python2 are included in 20.04. You have to install pip for Python 2 manually:
First, install Python 2:
sudo apt install python2
Then, follow https://pip.pypa.io/en/stable/installing/ , using python2:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python2 get-pip.py
You can run the second step with sudo. If you don't use sudo, you'll need to change PATH, as suggested by the installation message. Alternatively, and possibly better (since it doesn't change PATH), use
python2 -m pip
whenever you need pip2.
In my case, the curl command for downloading get-pip.py gave a syntax error on running sudo python get-pip.py.
But manual download by visiting https://bootstrap.pypa.io/ and downloading get-pip.py worked fine for me.
I've found that creating a virtualenv for Python 2.7 installs also pip
$ virtualenv -p python2 venv
$ . venv/bin/activate
$ pip --version
pip 20.0.2 from /home/.../venv/lib/python2.7/site-packages/pip (python 2.7)
Put python3 instead ${PYPKG} in line 202, and instead python-pip in line 596 in file install.sh of mininet-wifi.
To solve the problem of:
E: Unable to locate package python-pip
Run the package update index cmd:
sudo apt update
If not that, then python-pip-whl (which is also a package installer) is available in the universe repository, make sure that's installed and then run:
sudo apt-get install python-pip-whl
I specifically needed a Dockerfile file and this is what I have put inside so that it works without errors, I hope it will help someone.
This is Dockerfile file:
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python3 python3-dev
WORKDIR /app
COPY . /app
ENV DEBUG=True
EXPOSE 80

How to Install pip for python 3.7 on Ubuntu 18?

I've installed Python 3.7 on my Ubuntu 18.04 machine. Following this instructions in case it's relevant:
Download : Python 3.7 from Python Website [1] ,on Desktop and manually
unzip it, on Desktop Installation : Open Terminal (ctrl +shift+T)
Go to the Extracted folder
$ cd ~/Desktop/Python-3.7.0
$ ./configure
$ make
$ sudo make install
Making Python 3.7 default Python :
$ sudo vim ~/.bashrc
press i
on the last and new line - Type
alias python= python3.7
press Esc
type - to save and exit vim
:wq
now type
$ source ~/.bashrc
From here: https://www.quora.com/How-can-I-upgrade-Python-3-6-to-3-7-in-Ubuntu-18-04
I've downloaded several modules through pip install module but when I try to import them, I get a ModuleNotFoundError: No module names 'xx'
So I did some research and apparently when used pip to install, it installed in the modules in previous version of Python.
Somewhere (probably a question in SO) I found a suggestion to install the module using python3.7 -m pip install module but then I get /usr/local/bin/python3.7: no module named pip.
Now I'm stuck, pip is installed, but apparently not for Python 3.7. I'm assuming that if I can install pip for Python 3.7, I can run the pip install command and get the modules I need.
If that is the case, how can I install pip for python 3.7, since it's already installed?
This is the best I have come up with:
I have installed python 3.7 successfully and I can install modules using pip (or pip3) but those modules are installed in Python 3.6 (Comes with ubuntu). Therefore I can't import those modules in python 3.7 (get a module not found)
Python 3.7 doesn't recognize pip/pip3, so I can't install through pip/pip3
I need python 3.7
In general, don't do this:
pip install package
because, as you have correctly noticed, it's not clear what Python version you're installing package for.
Instead, if you want to install package for Python 3.7, do this:
python3.7 -m pip install package
Replace package with the name of whatever you're trying to install.
Took me a surprisingly long time to figure it out, too. The docs about it are here.
Your other option is to set up a virtual environment. Once your virtual environment is active, executable names like python and pip will point to the correct ones.
A quick add-on to mpenkov's answer above (didn't want this to get lost in the comments)
For me, I had to install pip for 3.6 first
sudo apt install python3-pip
now you can install python 3.7
sudo apt install python3.7
and then I could install pip for 3.7
python3.7 -m pip install pip
and as a bonus, to install other modules just preface with
python3.7 -m pip install <module>
EDIT 1 (12/2019):
I know this is obvious for most. but if you want python 3.8, just substitute python3.8 in place of python3.7
EDIT 2 (5/2020):
For those that are able to upgrade, Python 3.8 is available out-of-the-box for Ubuntu 20.04 which was released a few weeks ago.
This works for me.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Then this command with sudo:
python3.7 get-pip.py
Based on this instruction.
I used apt-get to install python3.7 in ubuntu18.04. The installations are as follows.
install python3.7
sudo apt-get install python3.7
install pip3. It should be noted that this may install pip3 for python3.6.
sudo apt-get install python3-pip
change the default of python3 for python3.7. This is where the magic is, which will make the pip3 refer to python3.7.
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
Hope it works for you.
To install all currently supported python versions (python 3.6 is already pre-installed) including pip for Ubuntu 18.04 do the following:
To install python3.5 and python3.7, use the deadsnakes ppa:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.5
sudo apt-get install python3.7
Install python2.7 via distribution packages:
sudo apt install python-minimal # on Ubuntu 18.04 python-minimal maps to python2.7
To install pip use:
sudo apt install python-pip # on Ubuntu 18.04 this refers to pip for python2.7
sudo apt install python3-pip # on Ubuntu 18.04 this refers to pip for python3.6
python3.5 -m pip install pip # this will install pip only for the current user
python3.7 -m pip install pip
I used it for setting up a CI-chain for a python project with tox and Jenkins.
Combining the answers from #mpenkon and #dangel, this is what worked for me:
sudo apt install python3-pip
python3.7 -m pip install pip
Step #1 is required (assuming you don't already have pip for python3) for step #2 to work. It uses pip for Python3.6 to install pip for Python 3.7 apparently.
When i use apt install python3-pip, i get a lot of packages need install, but i donot need them. So, i DO like this:
apt update
apt-get install python3-setuptools
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm -f get-pip.py
The following steps can be used:
sudo apt-get -y update
---------
sudo apt-get install python3.7
--------------
python3.7
-------------
curl -O https://bootstrap.pypa.io/get-pip.py
-----------------
sudo apt install python3-pip
-----------------
sudo apt install python3.7-venv
-----------------
python3.7 -m venv /home/ubuntu/app
-------------
cd app
----------------
source bin/activate
Install python pre-requisites
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
Install python 3.7 (from ppa repository)
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7
Install pip3.7
sudo apt install python3-pip
python3.7 -m pip install pip
Create python and pip alternatives
sudo update-alternatives --install /usr/local/bin/python python /usr/bin/python3.7 10
sudo update-alternatives --install /usr/local/bin/pip pip /home/your_username/.local/bin/pip3.7 10
Make changes
source ~/.bashrc
python --version
pip --version
For those who intend to use venv:
If you don't already have pip for Python 3:
sudo apt install python3-pip
Install venv package:
sudo apt install python3.7-venv
Create virtual environment (which will be bootstrapped with pip by default):
python3.7 -m venv /path/to/new/virtual/environment
To activate the virtual environment, source the appropriate script for the current shell, from the bin directory of the virtual environment. The appropriate scripts for the different shells are:
bash/zsh – activate
fish – activate.fish
csh/tcsh – activate.csh
For example, if using bash:
source /path/to/new/virtual/environment/bin/activate
Optionally, to update pip for the virtual environment (while it is activated):
pip install --upgrade pip
When you want to deactivate the virtual environment:
deactivate
I installed pip3 using
python3.7 -m pip install pip
But upon using pip3 to install other dependencies, it was using python3.6.
You can check the by typing pip3 --version
Hence, I used pip3 like this (stated in one of the above answers):
python3.7 -m pip install <module>
or use it like this:
python3.7 -m pip install -r requirements.txt
I made a bash alias for later use in ~/.bashrc file as alias pip3='python3.7 -m pip'. If you use alias, don't forget to source ~/.bashrc after making the changes and saving it.
How about simply
add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install python3.7-dev
alias pip3.7="python3.7 -m pip"
Now you have the command
pip3.7
separately from pip3.
curl https://bootstrap.pypa.io/get-pip.py | sudo python3.7
if all else fails.
pip3 not pip. You can create an alias like you did with python3 if you like.

Recommended way to install pip(3) on centos7

I am interrested in knowing the recommended way to install pip3 for python3.6 (as of today, may 2018) on current version of centos7 (7.5.1804) and the accepted answer of How to install pip in CentOS 7? seems to be outdated because:
yum search -v pip
outputs (among other things):
python2-pip.noarch : A tool for installing and managing Python 2 packages
Repo : epel
python34-pip.noarch : A tool for installing and managing Python3 packages
Repo : epel
and python34-pip seems to be a (newer?) simpler way than the accepted answer of How to install pip in CentOS 7? :
sudo yum install python34-setuptools
sudo easy_install-3.4 pip
But since the versions of python installed on my machine are 2.7.5 and 3.6.3 why is it python34-pip and not python36-pip ? Is pip the same for 3.4+ (up to current 3.6.3) ?
Is pip the same for 3.4+
No, it's not. A single pip installation serves a single Python distribution (pip2.7/pip3.4/pip3.5 etc).
Since Python 3.5, pip is already bundled with the python distribution, so you can just run python3.6 -m pip instead of pip.
Python 3.6 is not available in CentOS 7 vanilla repo. I usually resort to IUS repo when needing to install a fresh Python on CentOS. It always has the most recent Python version, the current one being 3.6.5. It also offers a correspondent pip package.
$ yum install https://centos7.iuscommunity.org/ius-release.rpm
$ yum install python36u python36u-devel python36u-pip
Unfortunately, IUS doesn't offer a package for Python 3.7 yet so if you are looking for Python 3.7 on CentOS 7, building from source is your only option.
Edit: when yum is not an option
You should prefer the bootstrapping solution described in this answer as it is the most reliable way to get a working pip installed.
To install pip for python 3.6 on CentOS 7 you need to run
$ python3.6 -m ensurepip
Follow these commands in Centos 7
yum install python36
yum install python36-devel
yum install python36-setuptools
easy_install-3.6 pip
to check the pip version:
pip3 -V
pip 18.0 from /usr/local/lib/python3.6/site-packages/pip-18.0-py3.6.egg/pip (python 3.6)
There is now a python3-pip package in the CentOS 7 base repository as of 2019-08-22. There is no longer a need for third-party repositories or packages.
Installing python3-pip will also install libtirpc, python3, python3-libs, and python3-setuptools:
yum install --assumeyes python3-pip
You can now verify the version (yes, it is old, but it's what is coming from the base repository):
$ pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
If you don't want to stray from the files provided by the python3-pip package, and you don't want to see warnings about pip being old, see https://stackoverflow.com/a/46288945/534275 for silencing the messages.
Pip is not bundled in the EPEL version of python 3.6 for some reason. I assume a decent amount of people (such as me) will find this page because of that.
$ sudo yum install -y python36
...
$ python36 -m pip
/usr/bin/python36: No module named pip
So in this case, the setuptools package was the easiest solution.
$ sudo yum install python36-setuptools
$ sudo easy_install-3.6 pip
...
$ python36 -m pip --version
pip 18.0 from /usr/local/lib/python3.6/site-packages/pip-18.0-py3.6.egg/pip (python 3.6)
In case you're seeing that pip3 is linked to python2 path:
$ pip3 -V
pip 8.1.2 from /usr/lib/python2.7/site-packages/pip (python 2.7)
You'll probably get:
$ pip3 install --upgrade pip
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Then try to clear commands cache with hash -r. This has worked for me:
# Install Python 3:
sudo yum install python36 -y
# Install & Upgrade pip3
sudo python36 -m pip install --upgrade pip
# Validate pip3 installation:
sudo python3.6 -m ensurepip
# Successfully installed pip-10.0.1 setuptools-39.0.1
# Clear commands cache
hash -r
# might be required if getting in bash: /usr/bin/pip3: No such file or directory)
pip3 -V
# pip 19.0.3 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
which pip3
# /usr/local/bin/pip3
pip2 -V
# pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
which pip2
# /usr/local/bin/pip2
# Install your Python3 module:
sudo /usr/local/bin/pip3 install {required module for python3}
I got this error when I tried to install python36 over the built-in centos7 python 2.7.5 version:
Transaction check error:
file /etc/rpm/macros.python from install of python-rpm-macros-3-32.el7.noarch conflicts with file from package python-devel-2.7.5-80.el7_6.x86_64
And I fixed it with these:
yum install python36
yum update python-devel
yum install python36-devel
easy_install-3.6 pip
Try This::
sudo yum update
sudo yum install -y python36u python36u-libs python36u-devel python36u-pip
Working for me perfectly.

Categories

Resources