1

Attempting to run a python 2.7 app engine app locally using PyCharm (which uses dev_appserver) my machine is python 3.7 but I have a python 2.7 virtual env setup as the project interpreter, which works fine when running the project.

However when attempting to debug the same run config (which runs fine) I am getting the following error

ERROR: (dev_appserver) python2: command not found

I can run the python2 command in my terminal both inside and outside the virtual environment so I am not sure what is wrong here.

I am currently running Pop!_OS 20.04 LTS if that helps.

Jack Tidbury
  • 183
  • 1
  • 1
  • 12
  • I think your pycharm configuration is not picking up you virtual environment configuration and hence producing this message which is already addressed in https://stackoverflow.com/questions/61503849/google-dev-appserver-throws-error-python2-command-not-found-after-upgrade-to – Antonio Ramirez Jul 01 '20 at 22:45
  • @AntonioRamirez So this would seem a PyCharm Bug? The Debugger is not using the configured interpreter and instead reverting to the system interpreter? – Jack Tidbury Jul 02 '20 at 09:01
  • 1
    I have the same issue, and discovered that the server will run if "Attach to subprocess automatically while debugging" is deselected, however this means no breakpoints, so is pretty useless. Still - this may trigger a thought process for anyone reading ... – Gwyn Howell Jul 28 '20 at 12:19

2 Answers2

1

I have the same issue on mac catalina with Pycharm 2020.1.2. I was able to start the debugger by using a "Python configuration", rather than a "App Engine Server" configuration. Steps below:

  1. Click "Edit Configurations", and add a new "Python Configuration"
  2. In the Script Path, enter the full path to dev_appserver.py
  3. In Parameters, enter '--max_module_instances="default:1" .' (according to https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server#debugging_with_pdb)
  4. In Working Directory, enter the path to your project

This isn't perfect, but at least you can run the debugger within pycharm.

I look forward to a better answer some day that works with the "App Engine Server" configuration.

Gwyn Howell
  • 5,365
  • 2
  • 31
  • 48
0

I had the same issue after starting new AppEngine projects on python 3. Initially, I thought the problem was with a new version of Google Cloud SDK. I spent a lot of time linking/unlinking python versions and playing around the environment variables. But eventually, update of PyCharm to 2021.1.2 fixed the issue.

crash843
  • 640
  • 3
  • 8