使用VSCode进行OSGEO4W和Python开发时出现问题

2024-06-02 10:41:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用VSCode作为OSGEO4W开发的编辑器。我可以编写、调试和运行我的程序,但左侧的“大纲”窗口(这是非常必要的)不起作用。 查看Python输出时,出现以下错误消息:

InvalidPythonEnvironment: Could not get version information for 'C:\\OSGEO4~1\\bin\\python.exe': InternalError(u'The subprocess C:\\OSGEO4~1\\bin\\python.exe has crashed (EOFError(), stderr=).',)

我正在使用此批处理文件启动VSCode:

rem @echo off
set OSGWO4W_ROOT=C:\OSGeo4W64

REM Setting HOME is necessary for VSCode
REM in order to find the global .gitignore-file
SET HOME=H:\

call "%~dp0\o4w_env.bat"
@echo off

path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Qt4\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python27\Scripts

SET PYTHONPATH=%OSGEO4W_ROOT%\apps\python27\lib;%OSGEO4W_ROOT%\apps\python27\lib\site-packages;%OSGEO4W_ROOT%\bin;%PYSC_DIR%\Lib;C:\Users\<username>\AppData\Roaming\python\Python27\site-packages;

path %PATH%;C:\Program Files\Git\cmd
path %PATH%;C:\Program Files\Microsoft VS Code\bin
path %PATH%;C:\Program Files\dotnet\;C:\Windows\system32;c:\Windows;c\OSGeo4W64\bin;%OSGEO4W_ROOT%\


set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000

set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qt5\plugins

path %PATH%;%OSGEO4W_ROOT%

start /d "C:\Program Files\Microsoft VS Code\" Code.exe

在标准python安装中使用VSCode时,一切正常

VSCode版本:1.47.2 Python:2.7.16 64位


Tags: appspathechoforbincodefilesprogram