[Solved] ImportError when running dev_appserver.py from pycharm

I’m using the latest version of pycharm 2018.2, on Windows.
I’ve also updated the Google Cloud Sdk to the latest versions too.

When I use the built in App Engine run configuration in Pycharm:
enter image description here
I get an import error ImportError: cannot import name _common appearing in the run window:

"C:Program FilesJetBrainsPyCharm 2018.1.1binrunnerw.exe" C:Codemy- 
 projectenvScriptspython.exe "C:/Program Files (x86)/Google/Cloud 
 SDK/google-cloud-sdk/bin/dev_appserver.py" --port 8484 app.yaml tasks.yaml 
 longtasks.yaml --log_level=debug Traceback (most recent call last):
 File "C:/Program Files (x86)/Google/Cloud SDK/google-cloud- 
 sdk/bin/dev_appserver.py", line 12, in <module>
   from bootstrapping import bootstrapping
  File "C:Program Files (x86)GoogleCloud SDKgoogle-cloud-   
   sdkbinbootstrappingbootstrapping.py", line 24, in <module>
  from . import setup  # pylint:disable=g-import-not-at-top
  File "C:Program Files (x86)GoogleCloud SDKgoogle-cloud- 
  sdkbinbootstrappingsetup.py", line 55, in <module>
  from googlecloudsdk.core import properties
  File "C:Program Files (x86)GoogleCloud SDKgoogle-cloud- 
  sdklibgooglecloudsdkcoreproperties.py", line 36, in <module>
  from googlecloudsdk.core.util import times
  File "C:Program Files (x86)GoogleCloud SDKgoogle-cloud- 
  sdklibgooglecloudsdkcoreutiltimes.py", line 55, in <module>
  from dateutil.tz import _common as tz_common
  ImportError: cannot import name _common

  Process finished with exit code 1

The dateutil.tz package is located in C:Python27Libsite-packages and I have a dateutil package in the project I’m running. I don’t know whether that has something to do with the issue. I’ve tried changing the default python interpreter which also did not work. I’ve tried running Pycharm as administrator which also had no effect. Both the debug and non-debug run commands result in this issue.

If I run the command to start up dev_appserver.py directly in the terminal (with or without virtual environment python), it works correctly e.g. "C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin/dev_appserver.py" --port 8484 app.yaml tasks.yaml longtasks.yaml

Also, if I run the command that pycharm is running (except for the runnerw part), then it works correctly (from command line) too:

C:Codeproject>C:CodeprojectenvScriptspython.exe "C:/Program Files 
(x86)/Google/Cloud SDK/google-cloud-sdk/bin/dev_appserver.py" --port 8484 
 app.yaml tasks.yaml longtasks.yaml --log_level=debug
 INFO     2018-07-29 08:11:15,566 devappserver2.py:178] Skipping SDK update 
 INFO     2018-07-29 08:11:17,726 api_server.py:274] Starting API server at: 
 INFO     2018-07-29 08:11:18,259 dispatcher.py:270] Starting module 
   "default" running at: http://localhost:8484
 INFO     2018-07-29 08:11:18,519 dispatcher.py:270] Starting module "tasks" 
 running at: http://localhost:8485
 INFO     2018-07-29 08:11:18,815 dispatcher.py:270] Starting module 
"longtasks" running at: http://localhost:8486
INFO     2018-07-29 08:11:18,822 admin_server.py:152] Starting admin server 
at: http://localhost:8000

It’s also worth noting that I can run other GAE projects in Pycharm and they do run (which leads me to think it’s something to do with my configuration of this project).

Solution #1:

This is a bug in 2018.2.4 of PyCharm Pro. I had the same issue, and rolled back to 2018.1.5 and it worked fine.

The problem is that 2018.2.4 is loading the cloud-sdk appengine flexible environment classes instead of the standard environment classes.

Respondent: Rob Curtis

Solution #2:

A hacky way to overcome this is to open <path-to...>/googlecloudsdk/core/util/times.py in a text editor and comment out

from dateutil.tz import _common as tz_common


tz_common.PY3 = True  # MONKEYPATCH!!! Fixes a Python 2 standard module bug.

Assuming you don’t need this “monkeypatch”, this solves the issue.

Respondent: user2061291

Solution #3:

I installed version 211.0.0

Followed by:

gcloud components install app-engine-python
Respondent: Josh Friedlander

Solution #4:

@user2061291’s comments it’s true. Pycharm is trying to run google-cloud-sdk/bin/dev_appserver.py. If you want to run app engine from pycharm anyway because you want to debug your code or something else then you should create a new python runner like this:

Script path:


For example:

Respondent: maxisme

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.