16

I installed pip, but if I try to install a package with

python -m pip install requests 

it says

/usr/local/bin/python: No module named pip 

How can I figure out where the problem is?

The problem is not with pip, but that the modules are not installed in the right way, so I can’t use them in Python. I am using Ubuntu 15.04 (Vivid Vervet).

7
  • 2
    Is pip installed? You can check with which pip. if there is no pip, start with the docs Commented Oct 8, 2015 at 18:47
  • You should update the question with what version of Linux you are using; anoop's answer should work for debian/ubuntu, Fedora/Redhat/CentOS require slightly different instructions. Commented Oct 8, 2015 at 18:55
  • pip is installed and im using Ubuntu 15.04 Commented Oct 8, 2015 at 18:58
  • Might sound silly, but if try to run just the pip command alone, what happens? Commented Oct 8, 2015 at 19:00
  • 1
    You installed python manually, while you should have used your distro's package management tools (apt-get/dpkg). Because of this, you have a broken installation of python. You have to fix that before you go further. Maybe start by removing what you put in /usr/local. Commented Oct 8, 2015 at 19:04

6 Answers 6

15

My situation is that the Python 3 works fine, but pip 3 does not work (the default Python version is Python 2.7, but it doesn't matter).

I solve this problem by the following command:

apt-get purge python3-pip apt-get install -y python3-pip 

And if you are not the root user, you may need to add sudo in the beginning of the command.

Sign up to request clarification or add additional context in comments.

Comments

2

My openSUSE box at work did not have pip installed and YaST did not find it. I figured out that YaST was only pointing to a local package-repository which apparently was missing pip.

I have added the official openSUSE repository, which I found on Package repositories and then was able to find and install pip.

Comments

1

Pip is a Python packaging module that helps us to install Python libraries. To install Python libraries/modules, you need to install pip -

sudo apt-get install python-setuptools sudo easy_install pip sudo apt-get update which pip # To check pip install or not pip install requests 

2 Comments

Successfully installed requests-2.8.0 ImportError: No module named requests
do like pip freeze | grep requests and check if requests is already installed or not ,also check if you are using a virtual environment.In case,if you are using virtual environmennts,you need to activate it using source env/bin/activate.
1

I had to do something similar, and tom's answer didn't quite work on DigitalOcean and Ubuntu 14.04.05 (Trusty Tahr).

apt-get install python-setuptools easy_install pip apt-get install python3-dev pip install --upgrade setuptools pip install cryptography pip install paramiko 

Comments

1

to install pip in the version you want: python3.VERSIONYOUINSTALLED -m ensurepip and then you can use with python3.VERSIONYOUINSTALLED -m pip install PACKAGEYOUWANT

Comments

-1

See if the package is installed in the site-packages of your Python version.

It gives the path where all your packages reside for particular Python version.

import sys, os; print os.sep.join([sys.prefix, 'lib', 'python' + sys.version[:3], 'site-packages']);

If you find requests there, then import requests should work. Otherwise, add the above path to your Python interpreter's path by using the below code.

import sys sys.path.append("<path>") 

1 Comment

In what context is the line containing "sys.version[:3]" to be executed? Why is there semicolon outside the code formatting? Please respond by editing (changing) your answer, not here in comments (without "Edit:", "Update:", or similar - the answer should appear as if it was written today).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.