Skip to main content
fix typo, add qgis Version number
Source Link
bennos
  • 2.1k
  • 1
  • 15
  • 30

There is a not well documented command build into OSGeo4W Shell which sets the shell up to python3 as Luke mentions

py3_env

Basically it sethsets your PYTHONHOME and the correct PATH. Then you can call Python3 with python3.

C:\>py3_env
C:\>SET PYTHONPATH=
C:\>SET PYTHONHOME=C:\OSGEO4~1\apps\Python36
C:\>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS 2 you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%

There is a not well documented command build into OSGeo4W Shell which sets the shell up to python3 as Luke mentions

py3_env

Basically it seth your PYTHONHOME and the correct PATH. Then you can call Python3 with python3.

C:\>py3_env
C:\>SET PYTHONPATH=
C:\>SET PYTHONHOME=C:\OSGEO4~1\apps\Python36
C:\>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%

There is a not well documented command build into OSGeo4W Shell which sets the shell up to python3 as Luke mentions

py3_env

Basically it sets your PYTHONHOME and the correct PATH. Then you can call Python3 with python3.

C:\>py3_env
C:\>SET PYTHONPATH=
C:\>SET PYTHONHOME=C:\OSGEO4~1\apps\Python36
C:\>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS 2 you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%
use OSGeo4W shell's built in command
Source Link
bennos
  • 2.1k
  • 1
  • 15
  • 30

To use Python3 withThere is a not well documented command build into OSGeo4W Shell which sets the standalone OSGeo4W shell you haveshell up to setpython3 as Luke mentions

py3_env

Basically it seth your PYTHONHOME and the PYTHONHOMEcorrect PATH. Then Then you can call Python3 with python3.

C:\>set\>py3_env
C:\>SET PYTHONPATH=
C:\>SET PYTHONHOME=C:\OSGeo4W64\apps\Python36\OSGEO4~1\apps\Python36
C:\>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%

To use Python3 with the standalone OSGeo4W shell you have to set the PYTHONHOME. Then you can call Python3 with python3.

C:\>set PYTHONHOME=C:\OSGeo4W64\apps\Python36
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%

There is a not well documented command build into OSGeo4W Shell which sets the shell up to python3 as Luke mentions

py3_env

Basically it seth your PYTHONHOME and the correct PATH. Then you can call Python3 with python3.

C:\>py3_env
C:\>SET PYTHONPATH=
C:\>SET PYTHONHOME=C:\OSGEO4~1\apps\Python36
C:\>PATH C:\OSGEO4~1\apps\Python36;C:\OSGEO4~1\apps\Python36\Scripts;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;C:\Windows\system32;C:\Windows;C:\Windows\WBem
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%
added version for OSGeo4W shipped with QGIS from comments
Source Link
bennos
  • 2.1k
  • 1
  • 15
  • 30

To use Python3 with OSGeo4W shellthe standalone OSGeo4W shell you have to set the PYTHONHOME. Then you can call Python3 with python3.

C:\>set PYTHONHOME=C:\OSGeo4W64\apps\Python36
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%

To use Python3 with OSGeo4W shell you have to set the PYTHONHOME. Then you can call Python3 with python3.

C:\>set PYTHONHOME=C:\OSGeo4W64\apps\Python36
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

To use Python3 with the standalone OSGeo4W shell you have to set the PYTHONHOME. Then you can call Python3 with python3.

C:\>set PYTHONHOME=C:\OSGeo4W64\apps\Python36
C:\>python3
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Update with auslander's comment:

To use Python3 with the OSGeo4W shell that comes with QGIS you have to change the file {path you installed qgis}\etc\ini\python-core.bat:

SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36
PATH %OSGEO4W_ROOT%\apps\Python36\Scripts;%PATH%
Source Link
bennos
  • 2.1k
  • 1
  • 15
  • 30
Loading