-1

I use OS LUbuntu

I installed Python3.4 using the Lubuntu software center; enter image description here

Next thing I want to do is to install some modules. Best way I can think of would be pip install. But I can't find it on the computer (I'm quite new to Linux).

Please help reaching the pip? or other way to install modules except pip?

I tried sudo apt-get install ... , but It installs it on python2.7 instead of python3.4 (I have 2 interpreters). Removing python2.7 off the computer is not an option..

Tal Rofe
  • 457
  • 12
  • 46
  • See [this](https://packaging.python.org/tutorials/installing-packages/). – iz_ Nov 26 '18 at 21:55
  • @Tomothy32 This is another option but I'd rather use the "sudo apt-get install..." option. But once I do it, it installs it on 2.7. I need it on 3.4 – Tal Rofe Nov 26 '18 at 21:58
  • @Tomothy32 - The python3 libraries in ubuntu have a `python3` prefix, e.g.: `sudo apt-get install python3-pil` – Kingsley Nov 26 '18 at 22:41
  • Possible duplicate of [Ubuntu, how to install OpenCV for python3?](https://stackoverflow.com/questions/37188623/ubuntu-how-to-install-opencv-for-python3) – phd Nov 26 '18 at 22:50
  • https://stackoverflow.com/search?q=%5Bpython%5D+%5Bubuntu%5D+install+opencv – phd Nov 26 '18 at 22:50

2 Answers2

0

Have you tried sudo apt-get install pip3?

Ok, as someone has pointed out it is not actually pip3, it is a symlink. For a better answer we can look at the official python documentation. https://docs.python.org/3/installing/index.html and here we find: python2 -m pip install SomePackage # default Python 2 python2.7 -m pip install SomePackage # specifically Python 2.7 python3 -m pip install SomePackage # default Python 3 python3.4 -m pip install SomePackage # specifically Python 3.4

So, if you want to install the Python 3 version of a package use

python3 -m pip install SomePackage # default Python 3

mikeg
  • 444
  • 3
  • 13
  • I have yet to try, because I still try to use "sudo apt-get install " rather than using pip3. Because I only need one module for temporary usage. Problem is, once I do this "sudo..." it installs it with 2.7. I need it to be installed with 3.7 – Tal Rofe Nov 26 '18 at 22:01
  • @mikeg There is no `pip3` in Debian/Ubuntu. – phd Nov 26 '18 at 22:49
  • Sorry, you are correct, there is no actual pip3. It is just a symlink to pip. So, lets look at the documentation. https://docs.python.org/3/installing/index.html. Here we see : py -2 -m pip install SomePackage # default Python 2 py -2.7 -m pip install SomePackage # specifically Python 2.7 py -3 -m pip install SomePackage # default Python 3 py -3.4 -m pip install SomePackage # specifically Python 3.4 – mikeg Nov 27 '18 at 09:22
0

You have stated that you want to use apt-get instead of pip, so:

sudo apt-get install python3-<package_name>

The important part of this is the 3. But honestly, pip is easier to use and more "meant" for Python, so I don't see a reason not to use it.

iz_
  • 15,923
  • 3
  • 25
  • 40