Skip to content

Error with PyInstaller during deployment of Azure function #1100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dchouren opened this issue Mar 5, 2019 · 6 comments
Closed

Error with PyInstaller during deployment of Azure function #1100

dchouren opened this issue Mar 5, 2019 · 6 comments

Comments

@dchouren
Copy link

dchouren commented Mar 5, 2019

Platform/OS: Linux Ubuntu
Regression From: Was working ~2 weeks ago

Bug description
I am developing an Azure function (Python) through VSCode. When I run 'func azure functionapp publish RootCauseAnalyzer --build-native-deps', I get a very long trace due to requirements.txt installing, culminating with this error:

  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  Complete output from command /root/.pyenv/versions/3.6.8/bin/python3.6 /root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpz2hhiyyp:
  Traceback (most recent call last):
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-zxjtt7kz/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 130, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-zxjtt7kz/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 112, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-zxjtt7kz/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 126, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 20, in <module>
      from PyInstaller import __version__ as version, HOMEPATH, PLATFORM
  ModuleNotFoundError: No module named 'PyInstaller'
  
  ----------------------------------------
Command "/root/.pyenv/versions/3.6.8/bin/python3.6 /root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpz2hhiyyp" failed with error code 1 in /tmp/pip-install-0d34rkni/pyinstaller
You are using pip version 19.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

My Dockerfile, if it's relevant:

FROM python:alpine

# If you prefer miniconda:
#FROM continuumio/miniconda3

LABEL Name=rca_vscode Version=0.0.1
EXPOSE 3000

WORKDIR /app
ADD . /app

# Using pip:
RUN python3 -m pip install -r requirements.txt
RUN pip install -U nltk
CMD ["python3", "-m", "rca_vscode"]

When I add the --no-bundler option I get:

func azure functionapp publish RootCauseAnalyzer --build-native-deps --no-bundler
Getting site publishing info...
Deleting the old .python_packages directory
Running 'docker pull mcr.microsoft.com/azure-functions/python:2.0'...done
Running 'docker run --rm -d mcr.microsoft.com/azure-functions/python:2.0'..done
Running 'docker exec -t 1351fd mkdir -p /home/site/wwwroot/'..done
Running 'docker cp /var/folders/xl/gfzrh7wx7wbdvpltpzq80dm40000gn/T/tmpn7al24tmp/. 1351fd:/home/site/wwwroot'..done
Running 'docker cp /var/folders/xl/gfzrh7wx7wbdvpltpzq80dm40000gn/T/tmpK2hsLb.tmp 1351fd:python_docker_build.sh'..done
Running 'docker cp /var/folders/xl/gfzrh7wx7wbdvpltpzq80dm40000gn/T/tmpM3HURN.tmp 1351fd:python_bundle_script.py'..done
Running 'docker exec -t 1351fd chmod +x /python_docker_build.sh'..done
Running 'docker exec -t 1351fd chmod +x /python_bundle_script.py'..done
Running 'docker exec -t 1351fd /python_docker_build.sh'...........................................................done
Running 'docker cp 1351fd:/app.zip /var/folders/xl/gfzrh7wx7wbdvpltpzq80dm40000gn/T/og2oibbp.4s3'..done
Running 'docker kill 1351fd'..done
Preparing archive...
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

Do you know what is happening with Pyinstaller? This same deployment flow was working about two weeks ago.

@dchouren
Copy link
Author

dchouren commented Mar 5, 2019

When I try to deploy straight from VSCode (UI, right click > 'Deploy to Function App') I get


> Executing task: . .env/bin/activate && func pack <

source activate root_cause_analyzer
pip download -r /Users/.../requirements.txt --dest /var/folders/xl/gfzrh7wx7wbdvpltpzq80dm40000gn/T/azureworker5mnd54r6

There was an error restoring dependencies.Traceback (most recent call last):
  File "/Users//miniconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users//miniconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/node_modules/azure-functions-core-tools/bin/tools/python/packapp/__main__.py", line 228, in <module>
    main()
  File "/usr/local/lib/node_modules/azure-functions-core-tools/bin/tools/python/packapp/__main__.py", line 54, in main
    find_and_build_deps(args)
  File "/usr/local/lib/node_modules/azure-functions-core-tools/bin/tools/python/packapp/__main__.py", line 73, in find_and_build_deps
    ], verbose=args.verbose)
  File "/usr/local/lib/node_modules/azure-functions-core-tools/bin/tools/python/packapp/__main__.py", line 46, in run_or_die
    run(cmd, verbose=verbose, check=True, **kwargs)
  File "/usr/local/lib/node_modules/azure-functions-core-tools/bin/tools/python/packapp/__main__.py", line 41, in run
    return subprocess.run(cmd, stdout=stdout, stderr=stderr, **kwargs)
  File "/Users//miniconda3/lib/python3.6/subprocess.py", line 403, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/Users//miniconda3/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/Users//miniconda3/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'pip'


The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

@dmitrysmirnovfinnair
Copy link

I have the same issue, can't redeploy, get:

  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  Complete output from command /root/.pyenv/versions/3.6.8/bin/python3.6 /root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpotxgdk37:
  Traceback (most recent call last):
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/root/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-49uajvza/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 130, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-49uajvza/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 112, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-49uajvza/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 126, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 20, in <module>
      from PyInstaller import __version__ as version, HOMEPATH, PLATFORM
  ModuleNotFoundError: No module named 'PyInstaller'

@dmitrysmirnovfinnair
Copy link

Oho, but adding this flag helped: --no-bundler, as per suggestion here: #1092

@dchouren
Copy link
Author

dchouren commented Mar 5, 2019

Closing. --no-bundler does indeed work for fixing any PyInstaller complications. I also had to update rolled key somewhere that was preventing auth and that was confusing me.

@karllhughes
Copy link

--no-bundler is deprecated.

Should we use --no-build for Python projects now?

@sevenam
Copy link

sevenam commented Dec 17, 2019

If anyone else run into this problem, try updating azure-functions-core-tools and/or azure-cli

@ghost ghost locked as resolved and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants