0

I tried to install numdifftools using the following command on my terminal (ubuntu 12.04):

sudo pip install numdifftools

and it installs it by default for python3.2. Is there a way to force it to install the package for version 2.7 instead

sudo python2.7 get-pip.py

/usr/lib/python2.7/dist-packages/setuptools/command/install_scripts.py:3: UserWarning: Module pip was already imported from /tmp/tmpByCdBF/pip.zip/pip/__init__.py, but /usr/lib/python2.7/dist-packages is being added to sys.path
  from pkg_resources import Distribution, PathMetadata, ensure_directory
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.6-py2.py3-none-any.whl#md5=4d4fb4b69df6731c7aeaadd6300bc1f2
  Downloading pip-1.5.6-py2.py3-none-any.whl (1.0MB): 1.0MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.0
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...
ra@ra-VGN-FZ19:~/python$ sudo pip install numdifftools
Requirement already satisfied (use --upgrade to upgrade): numdifftools in /usr/local/lib/python3.2/dist-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.4 in /usr/lib/python3/dist-packages (from numdifftools)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.8 in /usr/lib/python3/dist-packages (from numdifftools)
Cleaning up...
user3766123
  • 27
  • 1
  • 8
  • possible duplicate of http://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-python-versions – Blair Jul 03 '14 at 16:15
  • Thanks for directing me to that site. I have tried `sudo pip2.7 install numdifftools` and `sudo pip-2.7 install numdifftools` and none of it works. It seems like pip is in my 3.2 directory `pip show pip --- Name: pip Version: 1.5.6 Location: /usr/local/lib/python3.2/dist-packages/pip-1.5.6-py3.2.egg Requires: `, hence it is installing everything there. If so, how do I fix that? – user3766123 Jul 03 '14 at 17:02

1 Answers1

3

Install pip for python 2.7 as well;

  • Download get-pip.py.
  • Run python2.7 get-pip.py.

Or install it via your package manager of choice.

Then use pip2.7 to install stuff for Python 2.7.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
  • right before I saw your post, I installed pip from the package center. Can you help me understand how this is different from the pip on the package center. I have downloaded your file, and I want to understand what I am doing. – user3766123 Jul 03 '14 at 17:44
  • @user3766123 If you are using a packaging system, that's OK too. View the contents of the `get-pip.py` script e.g. with `less` or a text editor, and you'll see that it is basically a base64 encoded ZIP file that contains pip. :-) – Roland Smith Jul 03 '14 at 18:37
  • I just ran it and have updated my post with the error message. I am deleting the error message, as I could install it by using sudo, and I am updating my post with what it shows when I try to install numdifftools – user3766123 Jul 03 '14 at 18:46
  • @user3766123 There should be a `pip2.7`. Try using that. – Roland Smith Jul 04 '14 at 23:28
  • awesome, I ran `sudo pip2.7 install numdifftools` and it worked. thanks a bunch! – user3766123 Jul 05 '14 at 17:24