Installing pip using ArcGIS-installed Python 2.7

user3566911 picture user3566911 · Oct 27, 2014 · Viewed 7.5k times · Source

I'm trying to install Scrapy for Python 2.7 on Windows 8.1 and I understand that I first need pip to be installed. Since I have Python installed through ArcGIS 10.2, I think that I need to install pip under C:\Python27\ArcGIS10.2\lib\site-packages. Once pip is installed in that directory I receive the error code:

>>> import pip
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\ArcGIS10.2\lib\site-packages\pip\__init__.py", line 10, in <module>
    from pip.util import get_installed_distributions, get_prog
  File "C:\Python27\ArcGIS10.2\lib\site-packages\pip\util.py", line 18, in <module>
    from pip._vendor.distlib import version
  File "C:\Python27\ArcGIS10.2\lib\site-packages\pip\_vendor\distlib\version.py", line 14, in <module>
    from .compat import string_types
  File "C:\Python27\ArcGIS10.2\lib\site-packages\pip\_vendor\distlib\compat.py", line 38, in <module>
    from HTMLParser import HTMLParser
  File "C:\Python27\ArcGIS10.2\lib\HTMLParser.py", line 47, in <module>
    """, re.VERBOSE)
  File "C:\Python27\ArcGIS10.2\lib\re.py", line 190, in compile
    return _compile(pattern, flags)
  File "C:\Python27\ArcGIS10.2\lib\re.py", line 242, in _compile
    raise error, v # invalid expression
error: nothing to repeat

I've also installed pip in C:\Python27\lib\site-packages. However, when it is only installed in that directory PyScripter doesn't recognize that it is installed. Does anyone have any suggestions?

Answer

geo barry picture geo barry · Nov 13, 2014

I have a similar setup (Python installed through ArcGIS 10.2, but on machines running Windows 7 not 8.1). I used PIP to install another package (birdy instead of scrapy) and got it working. I think your problem may be trying to work from inside a Python interpreter instead of from the command line (oh, ye mighty Unix users with your ever-powerful command line). Here's what worked for me:

  1. Go to http://pip.readthedocs.org/en/latest/installing.html
  2. Download the get-pip.py file and place it in your python folder, e.g.: C:\python27\arcgis10.2\
  3. Start a command prompt (Start Menu >> Accessories >> Command Prompt)
  4. Change directories to python folder by entering: cd c:\python27\arcgis10.2
  5. Install PIP by entering: python get-pip.py
  6. Change directories into the scripts folder by entering: cd scripts
  7. Use pip to install your package (e.g. scrapy) by entering: pip install scrapy

If this works, you should be able to go into Python now and import scrapy. This worked for me on every computer in my lab... just not on my own laptop... will be writing up my own question for that soon (arghh!).