Bug report #16329

osgeo4w64, unable to run python3 in command box

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

Status:Closed
Priority:Normal
Assignee:-
Category:Build/Install
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

Description

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:

c:\\osgeo4w64\\OSGeo4W.bat

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

C:\\osgeo4w64>python3
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):

C:\\osgeo4w64>

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

History

#1 Updated by Richard Duivenvoorde over 7 years ago

Some googling:

http://stackoverflow.com/questions/18946286/python3-installed-successfully-but-cannot-be-opened-in-terminal

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

Indeed when I type:

C:\\osgeo4w64>path
PATH=C:\\OSGEO4~1\\apps\\Python27\\Scripts;C:\\OSGEO4~1\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\WBem;C:\\OSGEO4~1\\apps\\msys\\bin

it is pointing to the Python27 dir?

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

#2 Updated by Giovanni Manghi over 7 years ago

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

#3 Updated by Jürgen Fischer over 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