5

When I run dev_appserver.py on google-cloud-sdk, I get ImportError: No module named py27_urlquote.

Traceback (most recent call last):
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 109, in <module>
    _run_file(__file__, globals())
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 103, in _run_file
    _execfile(_PATHS.script_file(script_name), globals_)
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 83, in _execfile
    execfile(fn, scope)
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 44, in <module>
    from google.appengine.tools.devappserver2 import dispatcher
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 43, in <module>
    from google.appengine.tools.devappserver2 import module
  File "/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 39, in <module>
    import py27_urlquote
ImportError: No module named py27_urlquote

I have tried the following:

  1. Reinstall Cloud SDK
  2. Find out about the py27_urlquote module (I couldn't find any such information ...)
  3. Change the version of CLOUDSDK_PYTHON to 2.7 or 3.8 and execute
Bryan L
  • 550
  • 1
  • 9
Nakasei
  • 71
  • 7

2 Answers2

3

Right now this is a public issue and is currently being addressed by our Google Engineering Team. A workaround was provided for you to run your local development server:

  1. Install pip for Python 2
sudo apt update
sudo apt install python-pip
  1. Install urlquote instead of py27_urlquote
pip install urlquote
  1. Modify module.py located on your local directory from the error message
/Users/user/Downloads/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py
  1. Replace py27_urlquote to urlquote. There are 3 lines of code that uses py27_urlquote. Specifically lines 39, 833, and 836.

You can check this public tracker similar to your issue for more information and updates.

Robert G
  • 1,583
  • 3
  • 13
  • 1
    It seems that the equivalent call in urlquote is not `urlquote` but `quote`: https://pypi.org/project/urlquote/ . To make it work I've replaced the import with `from urlquote import quote` and the other two lines from `py27_urlquote.urlquote(...` to `quote(...` – penguin86 Oct 19 '21 at 09:39
  • Step 2 may need to be `pip2 install urlquote` – mleonard Nov 05 '21 at 12:51
3

I just encountered this problem too on the SDK version 359.0.0

Instead of updating the SDK files manually, I opted for downgrading to a previous version.

I found that version 357.0.0 works fine.

To downgrade, run the following command:

gcloud components update --version 357.0.0
Dharman
  • 30,962
  • 25
  • 85
  • 135
Mandi
  • 414
  • 1
  • 4
  • 12