title: Issue installing zip file created by setup.py for deploying custom prediction to AI platform
body: <p>Am following google doc on creating custom prediction(<a href="https://cloud.google.com/ai-platform/prediction/docs/custom-prediction-routines" rel="nofollow noreferrer">https://cloud.google.com/ai-platform/prediction/docs/custom-prediction-routines</a>). While building a new version for a model AI-platform prediction API threw below error:</p>
  <p><code>Error Create Version failed. Bad model detected with error: &quot;Failed to load model: User-provided package &lt;&gt;-0.1.tar.gz failed to install: Command '['python-default', '-m', 'pip', 'install', '--target=/tmp/custom_lib', '--no-cache-dir', '-b', '/tmp/pip_builds', '/tmp/custom_code/&lt;&gt;.tar.gz']' returned non-zero exit status 1. (Error code: 0)&quot;</code></p>
  <p>Was testing my zip file locally</p>
  <p><code>pip install --target=/tmp/custom_lib --no-cache-dir -b /tmp/pip_builds dist/&lt;&gt;</code></p>
  <p>Throws below error:</p>
  <pre><code>Processing ./dist/&lt;tar&gt;
      ERROR: Command errored out with exit status 1:
       command: bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'/private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' egg_info --egg-base /private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-pip-egg-info-ic3qhcpo
           cwd: /private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z/
      Complete output (6 lines):
      Parent directory: /private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z
      Traceback (most recent call last):
        File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
        File &quot;/private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z/setup.py&quot;, line 22, in &lt;module&gt;
          REQUIRED_PACKAGES = [line.strip() for line in open(base/&quot;requirements.txt&quot;)] + \
      FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/mj/b_g4b4yj26q278g9k58w92fck5d9wj/T/pip-req-build-9dmmje_z/requirements.txt'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  </code></pre>
  <p>Ran &quot;python setup.py egg_info&quot; on the mac terminal, nothing useful popped.</p>
  <pre class="lang-py prettyprint-override"><code>Parent directory: .
  
  Packages: ['numpy==1.17.3', 'pandas==1.2.1', 'setuptools==53.0.0', 'Pillow==6.2.1', 'torchvision==0.5.0', 'torch @ https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl']
  
  
  running egg_info
  writing &lt;&gt;.egg-info/PKG-INFO
  writing dependency_links to &lt;&gt;.egg-info/dependency_links.txt
  writing requirements to &lt;&gt;.egg-info/requires.txt
  writing top-level names to &lt;&gt;.egg-info/top_level.txt
  reading manifest file '&lt;&gt;.egg-info/SOURCES.txt'
  writing manifest file '&lt;&gt;.egg-info/SOURCES.txt'
  </code></pre>
  <p>Python packages:</p>
  <p><code>Packages: ['numpy==1.17.3', 'pandas==1.2.1', 'setuptools==53.0.0', 'Pillow==6.2.1', 'torchvision==0.5.0', 'torch @ https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl']</code></p>
  <p>Setup.py</p>
  <pre><code>from pathlib import Path
  &quot;&quot;&quot;
  Purpose: Package your Predictor and its dependencies by packaging  Predictor as a .tar.gz.
  
  For deploying any PyTorch model, the PyTorch package is needed to be provided in the below-mentioned command. In this case, 
  we have used the package:
  torch-1.3.1+cpu-cp37-cp37m-linux_x86_64.whl
  For getting pytorch packages according to your requirements,
  Visit this link: Pytorch Packages(google search)
  Download the package you require and store it in the GCS bucket.
  The package we are using provides version resource with PyTorch 1.3.1 for Python 3.7, built to run on a CPU in Linux.
  
  NOTE: We could have directly added ‘torch’ in the ‘REQUIRED_PACKAGES’ list in setup.py file in order to provide pytorch as a dependency to be installed while deployment.
  This way, it uses the PyPI installation of pytorch.
  But the issue with this approach is that it internally downloads PyPI package for pytorch which is of 720 MB Which causes the failure of our model deployment because the AI platform allows custom models of 500MB or below to be deployed on it.
  So it is recommended to provide a pytorch package manually using gsutil command under — package-uris.
  Try: pip install --target=/tmp/custom_lib --no-cache-dir -b /tmp/pip_builds &lt;&gt;.4.tar.gz for troubleshooting
  &quot;&quot;&quot;
  base = Path(__file__).parent
  print(f&quot;Parent directory: {base}&quot;)
  REQUIRED_PACKAGES = [line.strip() for line in open(base/&quot;requirements.txt&quot;)] + \
  ['torchvision==0.5.0', 'torch @ https://download.pytorch.org/whl/cpu/torch-1.4.0%2Bcpu-cp37-cp37m-linux_x86_64.whl']
  
  print(f&quot;\nPackages: {REQUIRED_PACKAGES}\n\n&quot;)
  
  setup(description=&quot;Extract features of a image&quot;,
        author=&lt;&gt;,
        author_email=&lt;&gt;,
        name=&lt;&gt;,
        version=&lt;&gt;,
        url='&lt;&gt;',
        install_requires=REQUIRED_PACKAGES,
        project_urls={
            'Documentation': 'https://cloud.google.com/ai-platform/prediction/docs/custom-prediction-routines#tensorflow',
            'Deploy': 'https://cloud.google.com/ai-platform/prediction/docs/deploying-models#gcloud_1',
            'Ai_platform troubleshooting': 'https://cloud.google.com/ai-platform/training/docs/troubleshooting',
            'Say Thanks!': ['https://medium.com/searce/deploy-your-own-custom-model-on-gcps-ai-platform-7e42a5721b43',
                            'https://stackoverflow.com/questions/61933879/unexpected-error-when-loading-the-model-problem-in-predictor-modulenotfounder',
                            'https://stackoverflow.com/questions/56428037/what-is-the-best-way-to-save-pil-image-in-json'],
            'google Torch wheels': &quot;http://storage.googleapis.com/cloud-ai-pytorch/readme.txt&quot;,
            'Torch &amp; torchvision wheels': &quot;https://download.pytorch.org/whl/torch_stable.html &quot;,
            'Raised issue with google github branch': &quot;https://github.com/GoogleCloudPlatform/python-docs-samples/issues/5257&quot;,
            &quot;Stackoverflow&quot;: &quot;https://stackoverflow.com/questions/65795374/gcp-ai-platform-error-when-creating-a-custom-predictor-model-version-trained&quot;
        },
      python_requires='~=3.7',
      scripts=[&lt;&gt;])```
  Have tried the usual upgrading python setuptools to 52.0.0, but can't seem to shake this error off. 
  </code></pre>