从 OSGeo4W 启动的命令窗口开始,我成功安装了与在 windows 7 上运行的 python 2.7 兼容的 fastkml python 包。
当我从命令窗口运行 python 时,我可以从 fastkml 包中导入 kml 模块。
但是,如果我从同一命令窗口启动 IDLE 用户界面并尝试从 fastkml 包中导入 kml 模块,则会收到如下错误:
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
> from fastkml import kml
>Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from fastkml import kml
File "C:\OSGeo4W\apps\Python27\lib\site-packages\fastkml\__init__.py", line 28, in <module>
from pkg_resources import get_distribution, DistributionNotFound
File "C:\OSGeo4W\apps\Python27\lib\site-packages\pkg_resources\__init__.py", line 77, in <module>
__import__('pkg_resources.extern.packaging.specifiers')
File "C:\OSGeo4W\apps\Python27\lib\site-packages\pkg_resources\extern\__init__.py", line 42, in load_module
__import__(extant)
File "C:\OSGeo4W\apps\Python27\lib\site-packages\pkg_resources\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\OSGeo4W\apps\Python27\lib\site-packages\pkg_resources\_vendor\packaging\specifiers.py", line 373, in Specifier
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
File "C:\OSGeo4W\apps\Python27\lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\OSGeo4W\apps\Python27\lib\re.py", line 242, in _compile
raise error, v # invalid expression
error: nothing to repeat
以下是用于启动 OSgeo4W 的 bat 文件中的代码,而 OSgeo4W 又会启动 IDLE
@echo off
set OSGEO4W_ROOT=%~dp0
rem Convert double backslashes to single
set OSGEO4W_ROOT=%OSGEO4W_ROOT:\\=\%
echo. & echo OSGEO4W home is %OSGEO4W_ROOT% & echo.
set PATH=%OSGEO4W_ROOT%\bin;%PATH%
rem Add application-specific environment settings
for %%f in ("%OSGEO4W_ROOT%\etc\ini\*.bat") do call "%%f"
CALL C:\Python27\Lib\idlelib\idle.bat
@echo on
@if [%1]==[] (echo run o-help for a list of available commands & cmd.exe /k) else (cmd /c "%*")