Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install python3 version of package via pip on Ubuntu?

I have both python2.7 and python3.2 installed in Ubuntu 12.04.
The symbolic link python links to python2.7.

When I type:

sudo pip install package-name 

It will default install python2 version of package-name.

Some package supports both python2 and python3.
How to install python3 version of package-name via pip?

like image 389
kev Avatar asked May 26 '12 03:05

kev


People also ask

How do I install a specific version of a Python package pip?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .

Can I use pip to install python3?

Note: On some systems where both Python 2 & Python 3 are installed, pip and pip3 will do different things. pip installs the Python 2 version of the package, and pip3 will install the Python 3 version of the package. it should install all the modules listed on the file.

Does Python 3.8 3 have pip?

The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.

Does Python 3.8 5 have pip?

Their Python distros don't include pip by default.


2 Answers

Ubuntu 12.10+ and Fedora 13+ have a package called python3-pip which will install pip-3.2 (or pip-3.3, pip-3.4 or pip3 for newer versions) without needing this jumping through hoops.


I came across this and fixed this without needing the likes of wget or virtualenvs (assuming Ubuntu 12.04):

  1. Install package python3-setuptools: run sudo aptitude install python3-setuptools, this will give you the command easy_install3.
  2. Install pip using Python 3's setuptools: run sudo easy_install3 pip, this will give you the command pip-3.2 like kev's solution.
  3. Install your PyPI packages: run sudo pip-3.2 install <package> (installing python packages into your base system requires root, of course).
  4. Profit!
like image 97
akaIDIOT Avatar answered Oct 07 '22 03:10

akaIDIOT


You may want to build a virtualenv of python3, then install packages of python3 after activating the virtualenv. So your system won't be messed up :)

This could be something like:

virtualenv -p /usr/bin/python3 py3env source py3env/bin/activate pip install package-name 
like image 25
Felix Yan Avatar answered Oct 07 '22 03:10

Felix Yan