1

I successfully installed Python3's Pip and SetupTool packages by:

sudo apt-get install python3-pip

but when I try to download/install any package for Python3 by:

pip install <package-name>

It says that I don't have python-pip. It looks like OS's default is Python2 but I don't want to use it or install packages for it. How can I use my installed Python3-pip and change system's default to Python3?

PS: Should I uninstall Ubuntu's default Python2? Would it help at all?

AER
  • 139
  • 8
Vynylyn
  • 85
  • 8

1 Answers1

2

Pip for Python 3

The Python 3 version of pip is pip3 so you would run:

pip3 install <package-name>

In general, you can run dpkg with the -L, --list option to see what files are in an installed package:

dpkg -L python3-pip

I just installed python3-pip to verify this and one of the files listed is /usr/bin/pip3.

The two versions of Python can quite happily co-exist with each other.

System Python 2

I wouldn’t advise uninstalling the Python 2 that came with Ubuntu as it’s required by useful tools and important OS utilities. There’s a Debian project to port its Python 2 OS code to Python 3 but they won’t be finished for some time.

As an experiment, I tried running sudo apt-get remove python and I was asked to confirm if I wanted to uninstall a long list of packages:

apturl blueman flashplugin-installer gconf2 gdebi gecko-mediaplayer gimp gir1.2-ibus-1.0 gksu gnome-mplayer gvfs-backends ibus inkscape iotop ipython libgda-5.0-4 libgda-5.0-common libgksu2-0
libgnomevfs2-0 libgnomevfs2-common libgnomevfs2-extra libsmbclient light-locker-settings lubuntu-desktop lubuntu-software-center mplayer2 ndiff offlineimap pidgin python python-apt python-aptdaemon
python-aptdaemon.gtk3widgets python-bs4 python-cairo python-chardet python-colorama python-crypto python-dateutil python-dbus python-debian python-decorator python-defer python-dev python-distlib
python-gi python-gi-cairo python-glade2 python-gobject python-gobject-2 python-gtk2 python-gudev python-html5lib python-imaging python-ldb python-lxml python-matplotlib python-mock
python-ndg-httpsclient python-nose python-notify python-ntdb python-numpy python-openssl python-pexpect python-pil python-pip python-pkg-resources python-psutil python-pyasn1 python-pyparsing
python-pysqlite2 python-requests python-samba python-scipy python-setuptools python-simplegeneric python-six python-sqlite python-talloc python-tdb python-tk python-tz python-urllib3 python-wheel
python-xdg python3-smbc samba-common-bin samba-libs smbclient system-config-printer-common system-config-printer-gnome transmission-gtk ubuntu-release-upgrader-gtk update-manager update-notifier
update-notifier-common vlc-plugin-samba

Needless to say, I didn’t confirm.

Anthony Geoghegan
  • 12,605
  • 7
  • 59
  • 62
  • Your answer was interestingly right. Yes, it is pip3! And yes you're right about uninstalling Python2. Based on the output that you've provided here, it looks like a dangerous decision for novice people like me! – Vynylyn May 28 '15 at 20:49
  • Pip3 worked and found my packages but at the end of installition it stopped by this error: `creating /usr/local/lib/python3.4/dist-packages/hazm error: could not create '/usr/local/lib/python3.4/dist-packages/hazm': Permission denied` Can you please help me fixing this one, too? – Vynylyn May 28 '15 at 20:53
  • `hazm` is the name of module I'm trying to install. – Vynylyn May 28 '15 at 20:54
  • @Vynylyn You probably need to preface the pip3 command with `sudo`. – Anthony Geoghegan May 28 '15 at 20:57
  • I thought that `pip3` is a Python's internal command, so I should not attach a `sudo` command at the begining. It worked perfectly! You were really helpful tonight. Thanks! – Vynylyn May 28 '15 at 21:03