Bug report #16329

osgeo4w64, unable to run python3 in command box

Added by Richard Duivenvoorde about 7 years ago. Updated about 7 years ago.

Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:24239


Trying to test a python problem in QGIS3 via python on cli in osgeo4w64 (installed via osgeo4w installer in c:\\osgeo4w64), I open a commandbox by running the bat file:


Then trying to start python3, I get the following (see also screendump)
(This is on WindowsServer2008 machine.)

GDAL 2.1.3, released 2017/20/01

Fatal Python error: Py_Initialize: unable to load the file system codec
File "C:\\OSGEO4~1\\apps\\Python27\\lib\\encodings\\__init__.py", line 123
raise CodecRegistryError,\\
SyntaxError: invalid syntax

Current thread 0x00001b60 (most recent call first):


py3.png (21.1 KB) Richard Duivenvoorde, 2017-03-09 12:56 AM


#1 Updated by Richard Duivenvoorde about 7 years ago

Some googling:


apperently it is mixing python2 and python3 stuff, because python2 is in path?

Indeed when I type:


it is pointing to the Python27 dir?

maybe a more thorough cleanup of PATH (only for python3.bat/bin?)

#2 Updated by Giovanni Manghi about 7 years ago

  • Target version set to Version 3.0
  • Category set to Build/Install

#3 Updated by Jürgen Fischer about 7 years ago

  • Status changed from Open to Closed

1. Not a QGIS issue.
2. run call py3_env.bat first (also call qt5_env.bat if you want to use PyQt5)
3. use python-qgis.bat (that runs both and provides the environment to import qgis)

Also available in: Atom PDF