Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Python ver. with GDAL Merge tool in QGIS 3 #26302

Closed
qgib opened this issue Mar 12, 2018 · 10 comments
Closed

Incorrect Python ver. with GDAL Merge tool in QGIS 3 #26302

qgib opened this issue Mar 12, 2018 · 10 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore

Comments

@qgib
Copy link
Contributor

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)
Original Redmine Issue: 18413
Affected QGIS version: 3.0.0
Redmine category:processing/gdal
Assignee: Joe Krienert


Used OSGeo4W64 installer for QGIS 3 and friends. Made sure GDAL libs were included.
When running GDAL Merge tool an error is raised similar to #17298
Adding...

python --version

... to the gdal_merge.bat indicates it is trying to use 2.7.5.


Related issue(s): #25196 (duplicates)
Redmine related issue(s): 17298


@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)


Error output:

2018-03-11T19:56:08	INFO	cmd.exe /C  gdal_merge.bat -pct -ot Float32 -of GTiff -o "C:/Users/Joe M. Krienert/Desktop/Output.tif" C:/Users/Joe M. Krienert/Desktop/ned03m37089a1.tif C:/Users/Joe M. Krienert/Desktop/ned03m37089b2.tif
2018-03-11T19:56:08	INFO	GDAL execution console output
            Python 2.7.5
			File "C:\OSGEO4~1\apps\Python36\lib\site.py", line 177
			      file=sys.stderr)
			        ^
			SyntaxError: invalid syntax

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Giovanni Manghi (@gioman)


So the error does not seems related to the python version, right?


  • category_id was changed from GDAL Tools to Processing/GDAL
  • status_id was changed from Open to Feedback
  • regression was changed from 0 to 1

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)


Should GDAL be using Python version 3.6 in QGIS 3? If so, then the Python version might be the problem. If not, then there might be something astray in the basic OSGeo4W64 installer?

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Giovanni Manghi (@gioman)


Joe Krienert wrote:

Should GDAL be using Python version 3.6 in QGIS 3? If so, then the Python version might be the problem. If not, then there might be something astray in the basic OSGeo4W64 installer?

yes, qgis 3 uses python 3.

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)


When opening the Python terminal plugin in QGIS 3 desktop and import/calling print (sys.version), the ver. stated is Python 3.
Could the GDAL merge error be associated with conflicting syntax of attempting to run Python 3 commands in a Python 2.7 environment?

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)


Python 2.7.5
File "C:\OSGEO4~1\apps\Python36\lib\site.py", line 177
      file=sys.stderr)
       ^
      Syntax Error: invalid syntax

Does this code snippet from the GDAL merge tool log suggest a conflict between the library (Python36) and active Python version (2.7.5)?

Seems anomolous that the Python plugin terminal tells Python 3 as the active version, but the processing tool call to GDAL states ver 2.7.5.

Does GDAL not support Python 3?

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Joe Krienert (Joe Krienert)


This test suggest that GDAL is switching the active python version from v. 3.6 to 2.7.

From a freshly opened (as admin) OSGeo4W shell...

Check the current ver. of Python in use:

C:\Windows\System32>python --version
Python 2.7.5

Oddly set to ver. 2.7.5, update to ver. 3 environment:

C:\Windows\System32>gdal-dev-py3-env
C:\Windows\System32>call gdal-dev-env.bat
C:\Windows\System32>SET GDAL_DATA=C:\OSGEO4~1\apps\gdal-dev\share\gdal
C:\Windows\System32>SET GDAL_DRIVER_PATH=C:\OSGEO4~1\apps\gdal-dev\bin\gdalplugins
C:\Windows\System32>PATH C:\OSGEO4~1\apps\gdal-dev\bin;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem;C:\OSGEO4~1\apps\msys\bin
C:\Windows\System32>call py3_env.bat
C:\Windows\System32>SET PYTHONPATH=
C:\Windows\System32>SET PYTHONHOME=C:\OSGEO4~1\apps\Python36
C:\Windows\System32>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\gdal-dev\bin;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem;C:\OSGEO4~1\apps\msys\bin
C:\Windows\System32>SET PYTHONPATH=C:\OSGEO4~1\apps\gdal-dev\pymod3\lib\site-packages;
C:\Windows\System32>PATH C:\OSGEO4~1\apps\gdal-dev\pymod3\scripts;C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\gdal-dev\bin;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem;C:\OSGEO4~1\apps\msys\bin

Verify environment ver. changed:

C:\Windows\System32>python --version
Python 3.6.0

Attempt GDAL merge:

C:\Windows\System32>gdal_merge.bat -pct -ot Float32 -of GTiff -o "C:/Users/Joe/Desktop/OUTPUT.tif" D:/Personal/ned03m37089a1.tif D:/Personal/ned03m37089a2.tif
  File "C:\OSGEO4~1\apps\Python36\lib\site.py", line 177
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

Double check Python environment ver:

C:\Windows\System32>python --version
Python 2.7.5

Why would calling GDAL merge reset the python environment ver?

@qgib
Copy link
Contributor Author

qgib commented Mar 12, 2018

Author Name: Jürgen Fischer (@jef-n)


python --version

... to the gdal_merge.bat indicates it is trying to use 2.7.5. to Used OSGeo4W64 installer for QGIS 3 and friends. Made sure GDAL libs were included.
When running GDAL Merge tool an error is raised similar to #25196
Adding...

python --version

... to the gdal_merge.bat indicates it is trying to use 2.7.5.

@qgib
Copy link
Contributor Author

qgib commented Mar 30, 2018

Author Name: Jürgen Fischer (@jef-n)


@qgib
Copy link
Contributor Author

qgib commented Jun 4, 2018

Author Name: Nyall Dawson (@nyalldawson)


This was fixed upstream in osgeo4w


  • resolution was changed from to up/downstream
  • status_id was changed from Feedback to Closed

@qgib qgib closed this as completed Jun 4, 2018
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority Processing Relating to QGIS Processing framework or individual Processing algorithms Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

No branches or pull requests

1 participant