Can't install module with python-pip properly

14,035

Solution 1

After you installed Python 2.7, did you install the Python 2.7 version of easy_install and PIP? The existing installations are configured to use Python 2.6 by default which may be causing your issue.

Solution 2

You are probably using pip linked to python2.6, instead of 2.7. If you have installed pip properly with python2.7, you can do:

pip-2.7 install requests

If not, try installing this way:

curl -O http://python-distribute.org/distribute_setup.py
[sudo] python2.7 distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
[sudo] python2.7 get-pip.py
Share:
14,035
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I would like to install a module but pip is not installing it in the right directory which I assume should be /usr/local/lib/python2.7/site-packages/. After all, I just installed Python 2.7.2 today. Originally I had 2.6.5 and had installed modules successfully there. So I think something is wrong with my Python path.

    How to have all my module installations go to the proper python2.7 directory?

    s3z@s3z-laptop:~$ pip install requests
    Requirement already satisfied: requests in /usr/local/lib/python2.6/dist-packages/requests-0.6.1-py2.6.egg
    Installing collected packages: requests
    Successfully installed requests
    s3z@s3z-laptop:~$ python
    Python 2.7.2 (default, Oct  1 2011, 14:26:08) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import requests
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named requests
    >>> ^Z
    [3]+  Stopped                 python
    

    Also here is what my Python directories look like now http://pastie.org/2623543

  • Admin
    Admin over 12 years
    I installed Python-PIP after installing Python 2.7.2. And yes, I did try installing with easy_install at first but quickly ran into troubles there too. I then re-installed setup tools w/ easy_install again which was placed in /usr/local/lib/python2.7/site-packages but even then it did not work.
  • Admin
    Admin over 12 years
    Ok I recompiled Python 2.7.2 from source, installed python-setuptools, did sudo easy_install pip and then sudo pip install requests worked fine.