Python 3 and later is not compatible when running dev_appserver.py

Asked 2 years ago, Updated 2 years ago, 71 views

https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu

In Ubuntu 14.04, we followed the above tutorial to install the Google Cloud SDK.

The goal is to move the GAE with go.Also, develop it on Ubuntu 14.04.

The SDK installation proceeded without any problems.
https://cloud.google.com/appengine/docs/standard/go/quickstart#test_the_application

of this procedure dev_appserver.py app.yaml

When I try, I get the following error and I can't run it.

$python-V
Python 2.7.9
$dev_appserver.py app.yaml
ERROR: Python 3 and later is not compatible with the Google Cloud SDK. Please use Python version 2.7.x.

If you have a compatible Python interpreter installed, you can use it by setting
The CLOUDSDK_PYTHON environment variable to point to it.

The default version of python is 2.7.9, but
It may be competing because it contains python3.
$which python3
/home/ludwig125/.pyenv/shims/python3

As stated in the error, I set CLOUDSDK_PYTHON to python 2.7, but it didn't change.
$which python 2.7
/usr/local/bin/python 2.7
$exportCLOUDSDK_PYTHON="/usr/local/bin/python 2.7"

Same as this
ERROR: Python 3 and later is not compatible with the Google Cloud SDK. Please use Python version 2.7.x.

Could someone tell me how to solve this problem?

google-cloud

2022-09-30 14:48

2 Answers

Judging from the python3 directory, pyenv seems to be using python, but pyenv is probably having a problem because it intercepts the python command in the sim executable file and determines which Python version to run on.

pyenv passes the path to ~/.pyenv/bin by configuring ~/.profile and so on, so commenting it out and removing the path to ~/.pyenv/bin should work.

exportPYENV_ROOT=\${HOME}/.pyenv
export PATH=\${PYENV_ROOT}/bin:\${PATH}

However, there are other applications created in python that affect you if you use pyenv, but I think you should change Python version control to the official pipenv instead of pyenv which has many side effects.


2022-09-30 14:48

Thank you for your comment.

[/usr/lib/google-cloud-sdk/platform/google_appengine/demos/go/helloworld] $python dev_appserver.py app.yaml
/usr/local/bin/python2:can't open file'dev_appserver.py': [Errno2] No such file or directory
[/usr/lib/google-cloud-sdk/platform/google_appengine/demos/go/helloworld] $

It says that dev_appserver.py cannot be found in /usr/local/bin/python2...

(The icon has changed because it was sent from another machine.)

[Additional note]
If you specify a path, you can execute it. I will write it down again.
How to run python 2

$python2/usr/bin/dev_appserver.py app.yaml 


2022-09-30 14:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.