使用ArcGIS安装的Python 2.7安装pip [英] Installing pip using ArcGIS-installed Python 2.7

查看:793
本文介绍了使用ArcGIS安装的Python 2.7安装pip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Windows 8.1上安装适用于Python 2.7的Scrapy,我了解我首先需要安装pip.由于已通过ArcGIS 10.2安装了Python,因此我认为需要在C:\ Python27 \ ArcGIS10.2 \ lib \ site-packages下安装pip.在该目录中安装了pip后,我会收到错误代码:

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

我还在C:\ Python27 \ lib \ site-packages中安装了pip.但是,当仅将其安装在该目录中时,PyScripter无法识别已安装.有人有什么建议吗?

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?

推荐答案

我遇到了同样的问题,我通过真正干净地重新安装python来解决了这个问题.

I had the same problem, and I solved it by doing a really CLEAN reinstall of python.

我的ArcGIS版本再次从10.2.2升至10.3,再从10.2升至10.2.2.通过添加/删除程序"删除ArcGIS(或仅Python功能)后,C:\ Python27中的大多数文件都将被删除.但是,这不会从系统文件夹中删除python dll.取决于您的Window OS,它将是:

My version of ArcGIS has gone up and down from 10.2.2 to 10.3 to 10.2 to 10.2.2 again. When ArcGIS (or just the Python features) is removed via Add/Remove Programs, most of the files from C:\Python27 will be removed. However, this will not remove the python dll from your system folder. Depending on your Window OS, it will be either:

  • C:\ Windows \ System32 \ python27.dll
  • C:\ Windows \ SysWOW64 \ python27.dll

手动删除DLL,然后再次进行python安装.

Remove the DLL manually, and then do the python install again.

这应该为您提供了一个非常干净的python安装程序,然后再次运行get-pip.py,并且pip应该可以正常工作!

This should give your a really clean install of python, then run your get-pip.py again, and pip should work as expected!

P.S.如果您要降级python,则dll的删除非常重要.因为如果python升级了,python27.dll似乎会被替换,但是降级时却不会被替换.因此,python27.dll与C:\ Python27中的脚本之间不兼容.

P.S. The removing of the dll is really important if you are downgrading your python. As the python27.dll seem to get replaced if python is upgraded, but not when it is downgraded. Hence, there is incompatibility between python27.dll with the scripts in C:\Python27.

这篇关于使用ArcGIS安装的Python 2.7安装pip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆