I'm new to Ubuntu and I'm trying to learn python. I use pyCharm IDE and python 3.5 but now when I'm trying to install libraries using the sudo pip command they are installing to python 2.7, so when I'm running my script I get

ImportError: No module named  ... 

How should I install libraries via pip for Python 3?

  • Welcome to Ask Ubuntu. I'm not a python person, but the default python is Ubuntu 16.04 is python 2.7. To use python3 you type python3. pip defaults to the default python (thus 2.7), and you use pip3 to use the 'pip' for python3 (pip3 is found in package python3-pip) – guiverc Oct 11 at 11:26
  • @guiverc thx man its working now – Arman Trb Oct 11 at 11:59
  • 3
    Possible duplicate of ImportError: No module named easydict – karel Oct 12 at 2:08

I'm not a python person, but the default python in Ubuntu 16.04 is python 2.7. To use python3 you type python3.

pip applies to the default python (thus 2.7), and you use pip3 when you want to use the 'pip' for python3 (pip3 being found in package python3-pip)

You have to use pip3 for the python3 libraries.

Anything related to Python3 goes like this:

pip3 install library-name 

if this gives you authentication error, add --user

pip3 install --user  app-name

If you want to upgrade the specific app/library

pip3 install --user --upgrade app-name

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.