title: Google app engine deployment fails- Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')
body: <p>We are using command prompt <code>c:\gcloud app deploy app.yaml</code>, but get the following error:</p>
  <pre><code>Running &quot;python3 -m pip install --requirement requirements.txt --upgrade --upgrade-strategy only-if-needed --no-warn-script-location --no-warn-conflicts --force-reinstall --no-compile (PIP_CACHE_DIR=/layers/google.python.pip/pipcache PIP_DISABLE_PIP_VERSION_CHECK=1)&quot;
  Step #2 - &quot;build&quot;: /layers/google.python.pip/pip/bin/python3: Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')
  Step #2 - &quot;build&quot;: Done &quot;python3 -m pip install --requirement requirements.txt --upgr...&quot; (34.49892ms)
  Step #2 - &quot;build&quot;: Failure: (ID: 0ea8a540) /layers/google.python.pip/pip/bin/python3: Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')
  Step #2 - &quot;build&quot;: --------------------------------------------------------------------------------
  Step #2 - &quot;build&quot;: Running &quot;mv -f /builder/outputs/output-5577006791947779410 /builder/outputs/output&quot;
  Step #2 - &quot;build&quot;: Done &quot;mv -f /builder/outputs/output-5577006791947779410 /builder/o...&quot; (12.758866ms)
  Step #2 - &quot;build&quot;: ERROR: failed to build: exit status 1
  Finished Step #2 - &quot;build&quot;
  ERROR
  ERROR: build step 2 &quot;us.gcr.io/gae-runtimes/buildpacks/python37/builder:python37_20211201_3_7_12_RC00&quot; failed: step exited with non-zero status: 145
  </code></pre>
  <p>Our Requirements.txt is as below. We are currently on Python 3.7 standard app engine</p>
  <pre><code>firebase_admin==3.0.0
  sendgrid==6.9.3
  google-auth==1.35.0
  google-auth-httplib2==0.1.0
  jinja2==3.0.3
  MarkupSafe==2.0.1
  pytz==2021.3
  Flask==2.0.2
  twilio==6.46.0
  httplib2==0.20.2
  requests==2.24.0
  requests_toolbelt==0.9.1
  google-cloud-tasks==2.7.1
  google-cloud-logging==1.15.1
  googleapis-common-protos==1.54.0
  </code></pre>
  <p>Please help.The above code was working well before updating the requirements.txt file. We tried to remove gunicorn to allow the system pickup the latest according to documentation <a href="https://cloud.google.com/build/docs/view-build-results#viewing_build_results" rel="noreferrer">here</a>.</p>
  <p>We have a subdirectory structure that stores all the .py files in controllers and db definitions in models. Our main.py has the following -</p>
  <pre><code>sys.path.append(os.path.join(os.path.dirname(__file__), '../controllers'))
  sys.path.append(os.path.join(os.path.dirname(__file__), '../models'))
  </code></pre>
  <p>Does anyone know how to debug this error -  <code>Error while finding module specification for 'pip' (AttributeError: module '__main__' has no attribute '__file__')</code>. What does this mean?</p>