I have python3.7 and I want to install pip. However when I do the following:
sudo apt install python3-pip
It seems to download python version 3.6 and pip for that. Is there a way to not download python3.6 and just download pip for python3.7? It seems rather strange that pip is download a whole other package.
Download get-pip file
$curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Install pip for python3.7
$python3.7 get-pip.py
Check versions for both
$python3.7 -V && pip3 -V
Output:
Python 3.7.3
pip 19.1.1 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
if you check apt show python3-pip output you see it depends on python3:any (>= 3.4~) so it doesn't strictly say I need python3.6
I assume that you didn't install python3.7 using apt so as a result apt doesn't recognize that you have python3 and it tries to install it for you.
Deadsnakes
You can use a ppa called deadsnakes.
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.7
Then check that is has been installed successfully by running python3.7 --version. To use pip you can run python3.7 -m pip install package.
Compiling from source
You can build Python by yourself, on Debian based systems you would do:
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Download your preferred python version from https://www.python.org/ftp/python/
Then extract the tar archive and run make
./configure --enable-optimizations
make
sudo make altinstall
Then run python3.7 --version
try this.
python3.7 -m pip install pip
Related
I have made a mistake.
I have following this instructions.
Now i want to remove pip and then reinstall pip3.
If you are using Ubuntu, why not just use apt or apt-get?
sudo apt-get install python3-pip - to install pip3
sudo apt-get remove python3-pip- to remove pip
Assuming you installed pip for python3, not python.
Edit:
You should specify if you installed pip using Linux package manager or using script (get-pip.py)
Solution:
you need to execute the following command to install pip sudo apt-get
install python3-pip
and to remove you need to use sudo apt-get --purge autoremove
python3-pip
OK so I am a total noob and I just installed Kali Linux. I am trying to install python-pip by command
apt-get install python-pip
and I am getting this output
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
I've checked my source /ect/apt/sources.list and it says
deb http://http.kali.org/kali kali-last-snapshot main non-free contrib
I've run apt-get updates several times too and it's not helping. Please help.
At-First Open Your sources.list File With any Editor.
nano /etc/apt/sources.list
and add these Lines.
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
Not Update and Upgrade Your Kali Linux Using These Commands.
apt-get update
apt-get upgrade
and then Install pip using this command
apt-get install python-pip #For Python2
apt-get install python3-pip #For Python3
There is a high chance python-pip is not available, because 'python' is python2, and python2 is finally dead. Try to install python3-pip.
There is a convention that python without '3' is python2, and it's gonna last like that, I think, forever, due to compatibility reasons.
cd /
cd etc/apt/
sudo nano sources.list
After opening the editor paste the following line if not present.
deb http://http.debian.net/debian jessie-backports main
deb http://http.kali.org/kali kali-rolling main contrib non-free
run the following command
sudo apt upgrade
sudo apt install python-pip
This should work for you.
Try running apt-get install python3-pip. This will install pip3 on your machine.
I tried with sudo apt install python3-pip and didn't work. So I tried again with sudo apt-get install python3-pip and it worked fine. I'm using Kali Linux too.
You need to add the repositories to sources.list
nano /etc/apt/sources.list
And add
deb http://http.kali.org/kali kali-rolling main non-free contrib
deb-src http://http.kali.org/kali kali-rolling main non-free contrib
Save and run
apt-get update
apt-get upgrade
apt-get install python-pip #or python3-pip
And type
pip --version #or pip3
To more info click here and here
Use this to install pip for python 2.7:
curl https://bootstrap.pypa.io/2.7/get-pip.py -o get-pip.py
python get-pip.py
Now you have:
$ pip --version
pip 20.3.4 from /home/kali/.local/lib/python2.7/site-packages/pip (python 2.7)
$ pip3 --version
pip 21.0.1 from /home/kali/.local/lib/python3.9/site-packages/pip (python 3.9)
apt-get update
apt-get upgrade
This works
sudo apt update
sudo apt install python3
sudo apt install python3-pip
python3 -m pip install -r
This video helped me: https://www.youtube.com/watch?v=9EHUGDnvqoA
Try following commands:
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install python-pip
Hope it will help u!
Make your source.list like this
nano /etc/apt/source.list
deb http://http.kali.org/kali kali-last-snapshot main non-free contrib
deb http://http.kali.org/kali kali-rolling main non-free contrib deb-src
http://http.kali.org/kali kali-rolling main non-free contrib
Update Your kali
sudo apt-get update && upgrade
Now install python-pip
apt-get install python-pip or apt-get install python3-pip
It works for me:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py && python get-pip.py
If already python 2.7 version is installed , first remove that in cmd terminal
Type >> sudo apt purge -y python2-minimal
then install python latest version
Type >> sudo apt install -y python3-pip
python is installed!
Not found pip try this command
1: sudo apt install python3-pip
2: pip3 install -r requirements.txt
3: /usr/local/bin/python3.10 -m pip install --upgrade pip
i have same issue that i was using python2 not python3 you may check your python version you have
Try this :
sudo apt update
sudo apt install python3
sudo apt install python3-pip
python3 -m pip install -r
I had the same issue, here is the command that helped me:
sudo apt install python-pip
This command will install pip to your system.
I am trying to install gattlib in Python in order to use some of its Bluetooth-tools.
The OS is ubuntu 18.04.4 LTS.
I have by now tried the following (as e.g. here):
sudo apt-get install mercurial
hg clone https://bitbucket.org/OscarAcena/pygattlib
cd pygattlib
cat DEPENDS
sudo apt-get install libboost-thread-dev libboost-python-dev libbluetooth-dev libglib2.0-dev python-dev
sudo python3 setup.py install
which gives (my Python is 3.6.9):
usr/bin/ld: cannot find -lboost-python36
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
Also, I tried:
sudo apt install python3-gattlib
which gives:
the following packages have unmet dependencies:
python3-gattlib: Depends: python3 (>= 3.7~) but 3.6.7-1~18.04 is to be installed
Depends: libboost-python1.67.0 but is is not installable
Depends: libboost-thread1.67.0 but is is not installable
despite libboost-python and libboost-thread being successfully installed in the first attempt (see above), and python3 returning Python 3.6.9.
pip3 install gattlib
shows:
Building wheel for gattlib(setup.py) ... error
Running setup.py install for gattlib ... error
Which is the exact same result that I get from (following instructions from this question):
sudo pip3 download gattlib
sudo tar xvzf ./gattlib-0.20200122.tar.gz
cd gattlib-0.20200122/
sudo sed -ie 's/boost_python-py34/boost_python36/' setup.py
pip3 install .
in which I understand to be a necessary adjustment of the installation file before running it, because, if I understood correctly, the python version is somehow wrongly hardcoded in there.
Futher things I tried and that did not help:
pip3 install --upgrade setuptools
sudo apt-get install python3.6-dev libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
sudo apt-get install python-dev
sudo apt-get install libpython-dev
sudo apt-get install libevent-dev
sudo pip3 install gattlib
wget -qO- http://pike.esi.uclm.es/add-pike-repo.sh | sudo sh
sudo apt update
sudo apt install python3-gattlib
sudo apt-get install libbluetooth-dev
pip3 install --upgrade pip
sudo apt-get install mercurial
pip3 install gattlib
sudo apt-get install libboost-all-dev
cd /usr/lib/x86-64-linux-gnu
sudo ln -s libboost_python-py35.so libboost_python-py36.so
sudo apt-get install libbluetooth-dev bluez bluez-hcidump libboost-python-dev libboost-thread-dev libglib2.0-dev
hg clone https://bitbucket.org/OscarAcena/pygattlib
cd pygattlib
cat DEPENDS
sudo apt-get install libboost-thread-dev libboost-python-dev libbluetooth-dev libglib2.0-dev python-dev
sudo python3 setup.py install
sudo python setup.py install
pip3 install gTTS
sudo apt-get install python3 python-dev python3-dev \
build-essential libssl-dev libffi-dev \
libxml2-dev libxslt1-dev zlib1g-dev \
python-pip
sudo apt-get install aptitude
sudo aptitude install libboost-all-dev
I run
sudo python3 setup.py install
and I also get error
usr/bin/ld: cannot find -lboost-python36
because I don't have boost-python36.a but boost-python3-py36.a.
(I found this file using locate boost-python3 which uses database with filenames so it works faster then find but it may not be installed as default)
I had to edit setup.py and change
boost_libs = ["boost_python3"+str(sys.version_info.minor)]
to
boost_libs = ["boost_python3-py36"]
or more universal
boost_libs = ["boost_python3-py3"+str(sys.version_info.minor)]
Tested od Linux Mint 19.3 Tricia based on Ubuntu 18.04
You need to install python-dev that contains the header files for the Python C API. The following should do the trick (make sure to replace X with your Python version):
sudo apt-get install python3.X-dev
With ubuntu 20.04:
$ wget https://github.com/oscaracena/pygattlib/releases/download/v.20201113/python3-gattlib_0.20201113-1_amd64.deb
$ sudo apt install ./python3-gattlib*.deb
$ pip3 install gattlib
Reference:
https://pypi.org/project/gattlib/
NOTE: This didn't work for me!
sudo apt install pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python-dev
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>
I am chasing down an install failure. I have a fresh ubuntu xenial install. I have several different projects, each one involving dependencies requiring a different version of python, including a gnuradio project which seems to have the reasonable expectation that pip points to python2.7. Here is the first part of what I've run:
$ sudo apt-get update
$ sudo apt-get -yq upgrade
$ sudo apt-get -yq install python-pip
$ sudo pip install --upgrade pip
$ sudo apt-get install -yq python3-pip
$ sudo pip3 install --upgrade pip
$ sudo apt-get update
$ sudo apt-get -yq upgrade
$ sudo apt-get -yq install python-dev python3-dev
$ sudo apt-get install --fix-missing python-apt
$ sudo pip install numpy scipy matplotlib pybombs virtualenv
$ sudo apt-get -yq install build-essential libffi-dev libssl-dev python3-setuptools
$ sudo pip3 install --upgrade setuptools wheel
$ sudo pip3 install numpy scipy matplotlib virtualenv
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get install python3.6
$ sudo apt-get -yq install python3.6-venv python3.6-dev
$ sudo apt-get update
$ sudo apt-get upgrade
No complaints so far, when I check pip and pip3, they point where I want them to point:
$ pip -V
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
$ pip3 --version
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
Now I create a virtual environment for python3.6, enter it, in there pip points to python3.6 as expected, I install a few more packages, then exit the virtual environment and suddenly pip points to python3.5
$ mkdir projvenv
$ python3.6 -m venv /home/username/projvenv/
$ source /home/tom/vertexprojvenv/bin/activate
(projvenv) $ pip -V
pip 9.0.1 from /home/tom/projvenv/lib/python3.6/site-packages (python 3.6)
(projvenv) $ pip install numpy scipy matplotlib
(projvenv) $ deactivate
$ pip -V
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
I have looked at this question which seems to address a purely anaconda issue, while the solution does not apply in my case. This discussion is more to the point, and points to a problem with pip. That particular bug is at least not quite what is going on for me since I am able to upgrade both pip pointing to python2.7 and pip3 pointing to python3.5, and the pip hijacking is not initiated by an upgrade. Any wisdom shed on this problem is much appreciated.
(edit)
$ which pip
/usr/local/bin/pip
$ head -1 `which pip`
#!/usr/bin/python3
Restore shebang line in /usr/local/bin/pip — make it #!/usr/bin/python2.
PS. Well, formally it's not a complete answer because the question is "How to prevent?" I don't know what program changed shebang line; but I doubt it was virtual environment.