问:
How to Install PyMuPDF on Heroku Django
I am trying to make a script that extracts Images from PDF and I have made a script in a Django Project and added pymupdf to the requirements.txt.I Have an Aptfile with Mupdf in it and https://github.com/heroku/heroku-buildpack-apt as a buildpack along with heroku/python.While trying to push master to Heroku,The Push fails and here is the Error.</p>

```<code>    Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 322.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Apt app detected
remote: -----> Detected Aptfile or Stack changes, flushing cache
remote: -----> Adding custom repositories
remote: -----> Updating apt caches
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
remote:        Get:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [46.3 kB]
remote:        Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
remote:        Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
remote:        Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
remote:        Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/11 amd64 Packages [2,483 B]
remote:        Get:7 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [294 kB]
remote:        Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1,344 kB]
remote:        Get:9 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [817 kB]
remote:        Get:10 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [812 kB]
remote:        Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1,101 kB]
remote:        Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,343 kB]
remote:        Fetched 17.5 MB in 3s (5,813 kB/s)
remote:        Reading package lists...
remote: -----> Fetching .debs for mupdf
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        The following additional packages will be installed:
remote:          libopenjp2-7
remote:        Suggested packages:
remote:          mupdf-tools
remote:        The following NEW packages will be installed:
remote:          libopenjp2-7 mupdf
remote:        0 upgraded, 2 newly installed, 0 to remove and 46 not upgraded.
remote:        Need to get 19.2 MB of archives.
remote:        After this operation, 35.3 MB of additional disk space will be used.
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 libopenjp2-7 amd64 2.3.0-2build0.18.04.1 [145 kB]
remote:        Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 mupdf amd64 1.12.0+ds1-1 [19.0 MB]
remote:        Fetched 19.2 MB in 1s (13.5 MB/s)
remote:        Download complete and in download only mode
remote: -----> Installing libopenjp2-7_2.3.0-2build0.18.04.1_amd64.deb
remote: -----> Installing mupdf_1.12.0+ds1-1_amd64.deb
remote: -----> Writing profile script
remote: -----> Rewrite package-config files
remote: -----> Python app detected
remote: -----> Need to update SQLite3, clearing cache
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting bs4==0.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
remote:        Collecting Django==2.1.11 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/8c/49/d5038239995594281478bf209f8d93524ad342d500009a697b27f884668a/Django-2.1.11-py3-none-any.whl (7.3MB)
remote:        Collecting django-heroku==0.3.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote:        Collecting django-widget-tweaks==1.4.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 4))
remote:          Downloading https://files.pythonhosted.org/packages/1c/11/a8d3a4d73a09973d62ce381fb73a926707cb1485aa29599f2afc04dee7b4/django_widget_tweaks-1.4.5-py2.py3-none-any.whl
remote:        Collecting forex-python==1.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/1a/ff/f3f6da21e8fdc6ece355643871749c79a3191fed1cba088cbd0dc597dfee/forex-python-1.5.tar.gz
remote:        Collecting gunicorn==19.9.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 6))
remote:          Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote:        Collecting imageio==2.6.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/1a/de/f7f985018f462ceeffada7f6e609919fbcc934acd9301929cba14bc2c24a/imageio-2.6.1-py3-none-any.whl (3.3MB)
remote:        Collecting img2pdf==0.3.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 8))
remote:          Downloading https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz (80kB)
remote:        Collecting imutils==0.5.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 9))
remote:          Downloading https://files.pythonhosted.org/packages/b5/94/46dcae8c061e28be31bcaa55c560cb30ee9403c9a4bb2659768ec1b9eb7d/imutils-0.5.3.tar.gz
remote:        Collecting opencv-python-headless==4.1.2.30 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 10))
remote:          Downloading https://files.pythonhosted.org/packages/5d/96/b2824df85d8c5f148125e4fee073a62fde17639502fe67042b212ebfe488/opencv_python_headless-4.1.2.30-cp36-cp36m-manylinux1_x86_64.whl (21.8MB)
remote:        Collecting pandas==0.25.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)
remote:        Collecting Pillow==6.1.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 12))
remote:          Downloading https://files.pythonhosted.org/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
remote:        Collecting Pygments==2.4.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 13))
remote:          Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
remote:        Collecting pypandoc==1.4 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 14))
remote:          Downloading https://files.pythonhosted.org/packages/71/81/00184643e5a10a456b4118fc12c96780823adb8ed974eb2289f29703b29b/pypandoc-1.4.tar.gz
remote:        Collecting PyPDF2==1.26.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 15))
remote:          Downloading https://files.pythonhosted.org/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77kB)
remote:        Collecting scikit-image==0.16.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/c8/bb/771800366f41d66eef51e4b80515f8ef7edab234a3f244fdce3bafe89b39/scikit_image-0.16.2-cp36-cp36m-manylinux1_x86_64.whl (26.5MB)
remote:        Collecting whitenoise==5.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 17))
remote:          Downloading https://files.pythonhosted.org/packages/ae/25/0c8f08c9d3c93192cd286594f1e87b17bab496fb9082c2a69e17051b91fd/whitenoise-5.0.1-py2.py3-none-any.whl
remote:        Collecting xlrd==1.2.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 18))
remote:          Downloading https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl (103kB)
remote:        Collecting zipp==0.6.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl
remote:        Collecting python-docx (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/e4/83/c66a1934ed5ed8ab1dbb9931f1779079f8bca0f6bbc5793c06c4b5e7d671/python-docx-0.8.10.tar.gz (5.5MB)
remote:        Collecting pymupdf (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 21))
remote:          Downloading https://files.pythonhosted.org/packages/3d/6a/5b4d4f1964a0802f8f2514fcd1f8d53c7f1e74a55765f99df1cf482bbbe8/PyMuPDF-1.16.10.tar.gz (175kB)
remote:        Collecting beautifulsoup4 (from bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/cb/a1/c698cf319e9cfed6b17376281bd0efc6bfc8465698f54170ef60a485ab5d/beautifulsoup4-4.8.2-py3-none-any.whl (106kB)
remote:        Collecting pytz (from Django==2.1.11->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
remote:        Collecting dj-database-url>=0.5.0 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote:        Collecting psycopg2 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
remote:        Collecting requests (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
remote:        Collecting simplejson (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/98/87/a7b98aa9256c8843f92878966dc3d8d914c14aad97e2c5ce4798d5743e07/simplejson-3.17.0.tar.gz (83kB)
remote:        Collecting numpy (from imageio==2.6.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/62/20/4d43e141b5bc426ba38274933ef8e76e85c7adea2c321ecf9ebf7421cedf/numpy-1.18.1-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)
remote:        Collecting python-dateutil>=2.6.1 (from pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
remote:        Collecting matplotlib!=3.0.0,>=2.0.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/7e/07/4b361d6d0f4e08942575f83a11d33f36897e1aae4279046606dd1808778a/matplotlib-3.1.3-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
remote:        Collecting networkx>=2.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/41/8f/dd6a8e85946def36e4f2c69c84219af0fa5e832b018c970e92f2ad337e45/networkx-2.4-py3-none-any.whl (1.6MB)
remote:        Collecting PyWavelets>=0.4.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/59/bb/d2b85265ec9fa3c1922210c9393d4cdf7075cc87cce6fe671d7455f80fbc/PyWavelets-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (4.4MB)
remote:        Collecting scipy>=0.19.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1MB)
remote:        Collecting more-itertools (from zipp==0.6.0->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/72/96/4297306cc270eef1e3461da034a3bebe7c84eff052326b130824e98fc3fb/more_itertools-8.2.0-py3-none-any.whl (43kB)
remote:        Collecting lxml>=2.3.2 (from python-docx->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/dd/ba/a0e6866057fc0bbd17192925c1d63a3b85cf522965de9bc02364d08e5b84/lxml-4.5.0-cp36-cp36m-manylinux1_x86_64.whl (5.8MB)
remote:        Collecting soupsieve>=1.2 (from beautifulsoup4->bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/81/94/03c0f04471fc245d08d0a99f7946ac228ca98da4fa75796c507f61e688c2/soupsieve-1.9.5-py2.py3-none-any.whl
remote:        Collecting certifi>=2017.4.17 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
remote:        Collecting chardet<3.1.0,>=3.0.2 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting idna<2.9,>=2.5 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
remote:        Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
remote:        Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
remote:        Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
remote:        Collecting cycler>=0.10 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
remote:        Collecting kiwisolver>=1.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f8/a1/5742b56282449b1c0968197f63eae486eca2c35dcd334bab75ad524e0de1/kiwisolver-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (90kB)
remote:        Collecting decorator>=4.3.0 (from networkx>=2.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/8f/b7/f329cfdc75f3d28d12c65980e4469e2fa373f1953f5df6e370e84ea2e875/decorator-4.4.1-py2.py3-none-any.whl
remote:        Installing collected packages: soupsieve, beautifulsoup4, bs4, pytz, Django, dj-database-url, whitenoise, psycopg2, django-heroku, django-widget-tweaks, certifi, chardet, idna, urllib3, requests, simplejson, forex-python, gunicorn, numpy, Pillow, imageio, img2pdf, imutils, opencv-python-headless, six, python-dateutil, pandas, Pygments, pypandoc, PyPDF2, pyparsing, cycler, kiwisolver, matplotlib, decorator, networkx, PyWavelets, scipy, scikit-image, xlrd, more-itertools, zipp, lxml, python-docx, pymupdf
remote:          Running setup.py install for bs4: started
remote:            Running setup.py install for bs4: finished with status 'done'
remote:          Running setup.py install for psycopg2: started
remote:            Running setup.py install for psycopg2: finished with status 'done'
remote:          Running setup.py install for simplejson: started
remote:            Running setup.py install for simplejson: finished with status 'done'
remote:          Running setup.py install for forex-python: started
remote:            Running setup.py install for forex-python: finished with status 'done'
remote:          Running setup.py install for img2pdf: started
remote:            Running setup.py install for img2pdf: finished with status 'done'
remote:          Running setup.py install for imutils: started
remote:            Running setup.py install for imutils: finished with status 'done'
remote:          Running setup.py install for pypandoc: started
remote:            Running setup.py install for pypandoc: finished with status 'done'
remote:          Running setup.py install for PyPDF2: started
remote:            Running setup.py install for PyPDF2: finished with status 'done'
remote:          Running setup.py install for python-docx: started
remote:            Running setup.py install for python-docx: finished with status 'done'
remote:          Running setup.py install for pymupdf: started
remote:            Running setup.py install for pymupdf: finished with status 'error'
remote:            Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile:
remote:            running install
remote:            running build
remote:            running build_py
remote:            creating build
remote:            creating build/lib.linux-x86_64-3.6
remote:            creating build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__init__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/fitz.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/utils.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__main__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            running build_ext
remote:            building 'fitz._fitz' extension
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/fitz
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -I/app/.heroku/python/include/python3.6m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.6/fitz/fitz_wrap.o
remote:            fitz/fitz_wrap.c:2732:10: fatal error: fitz.h: No such file or directory
remote:             #include <fitz.h>
remote:                      ^~~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:
remote:            ----------------------------------------
remote:        Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-205xyxft/pymupdf/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to compare-tool.
remote:
To https://git.heroku.com/compare-tool.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/compare-tool.git'
</code>```

<p>`</p>

答:
I experienced exactly the same issue as you have described.

Prior to this, my Django Heroku app was working just fine with no issue using PyMuPDF / Fitz. So I was left to conclude that this build failure was a totally new problem resulting in some change.

In my case, I had just recently updated my dependencies which included PyMuPDF.

What solved my problem was to lock PyMuPDF at version 1.16.0.

pymupdf = "==1.16.0"

I think the latest version as of time of writing is either 1.16.1 or 1.16.2.

I am not 100% sure about the root cause but I suspect that it's because the latest version of PyMuPDF may not allow for backwards compatibility with older versions of pip.

Upon checking the pip version running on my live Heroku dyno, I get:

"You are using pip version 9.0.2, however version 20.0.2 is available."

If you are using the default Heroku Python environment, the same might apply to you.

Let us know if freezing your PyMuPDF version solves the issue for you as well!

Title: How to Install PyMuPDF on Heroku Django

Body:
I am trying to make a script that extracts Images from PDF and I have made a script in a Django Project and added pymupdf to the requirements.txt.I Have an Aptfile with Mupdf in it and https://github.com/heroku/heroku-buildpack-apt as a buildpack along with heroku/python.While trying to push master to Heroku,The Push fails and here is the Error.

    Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 322.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Apt app detected
remote: -----> Detected Aptfile or Stack changes, flushing cache
remote: -----> Adding custom repositories
remote: -----> Updating apt caches
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
remote:        Get:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [46.3 kB]
remote:        Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
remote:        Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
remote:        Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
remote:        Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/11 amd64 Packages [2,483 B]
remote:        Get:7 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [294 kB]
remote:        Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1,344 kB]
remote:        Get:9 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [817 kB]
remote:        Get:10 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [812 kB]
remote:        Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1,101 kB]
remote:        Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,343 kB]
remote:        Fetched 17.5 MB in 3s (5,813 kB/s)
remote:        Reading package lists...
remote: -----> Fetching .debs for mupdf
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        The following additional packages will be installed:
remote:          libopenjp2-7
remote:        Suggested packages:
remote:          mupdf-tools
remote:        The following NEW packages will be installed:
remote:          libopenjp2-7 mupdf
remote:        0 upgraded, 2 newly installed, 0 to remove and 46 not upgraded.
remote:        Need to get 19.2 MB of archives.
remote:        After this operation, 35.3 MB of additional disk space will be used.
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 libopenjp2-7 amd64 2.3.0-2build0.18.04.1 [145 kB]
remote:        Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 mupdf amd64 1.12.0+ds1-1 [19.0 MB]
remote:        Fetched 19.2 MB in 1s (13.5 MB/s)
remote:        Download complete and in download only mode
remote: -----> Installing libopenjp2-7_2.3.0-2build0.18.04.1_amd64.deb
remote: -----> Installing mupdf_1.12.0+ds1-1_amd64.deb
remote: -----> Writing profile script
remote: -----> Rewrite package-config files
remote: -----> Python app detected
remote: -----> Need to update SQLite3, clearing cache
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting bs4==0.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
remote:        Collecting Django==2.1.11 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/8c/49/d5038239995594281478bf209f8d93524ad342d500009a697b27f884668a/Django-2.1.11-py3-none-any.whl (7.3MB)
remote:        Collecting django-heroku==0.3.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote:        Collecting django-widget-tweaks==1.4.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 4))
remote:          Downloading https://files.pythonhosted.org/packages/1c/11/a8d3a4d73a09973d62ce381fb73a926707cb1485aa29599f2afc04dee7b4/django_widget_tweaks-1.4.5-py2.py3-none-any.whl
remote:        Collecting forex-python==1.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/1a/ff/f3f6da21e8fdc6ece355643871749c79a3191fed1cba088cbd0dc597dfee/forex-python-1.5.tar.gz
remote:        Collecting gunicorn==19.9.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 6))
remote:          Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote:        Collecting imageio==2.6.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/1a/de/f7f985018f462ceeffada7f6e609919fbcc934acd9301929cba14bc2c24a/imageio-2.6.1-py3-none-any.whl (3.3MB)
remote:        Collecting img2pdf==0.3.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 8))
remote:          Downloading https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz (80kB)
remote:        Collecting imutils==0.5.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 9))
remote:          Downloading https://files.pythonhosted.org/packages/b5/94/46dcae8c061e28be31bcaa55c560cb30ee9403c9a4bb2659768ec1b9eb7d/imutils-0.5.3.tar.gz
remote:        Collecting opencv-python-headless==4.1.2.30 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 10))
remote:          Downloading https://files.pythonhosted.org/packages/5d/96/b2824df85d8c5f148125e4fee073a62fde17639502fe67042b212ebfe488/opencv_python_headless-4.1.2.30-cp36-cp36m-manylinux1_x86_64.whl (21.8MB)
remote:        Collecting pandas==0.25.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)
remote:        Collecting Pillow==6.1.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 12))
remote:          Downloading https://files.pythonhosted.org/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
remote:        Collecting Pygments==2.4.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 13))
remote:          Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
remote:        Collecting pypandoc==1.4 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 14))
remote:          Downloading https://files.pythonhosted.org/packages/71/81/00184643e5a10a456b4118fc12c96780823adb8ed974eb2289f29703b29b/pypandoc-1.4.tar.gz
remote:        Collecting PyPDF2==1.26.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 15))
remote:          Downloading https://files.pythonhosted.org/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77kB)
remote:        Collecting scikit-image==0.16.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/c8/bb/771800366f41d66eef51e4b80515f8ef7edab234a3f244fdce3bafe89b39/scikit_image-0.16.2-cp36-cp36m-manylinux1_x86_64.whl (26.5MB)
remote:        Collecting whitenoise==5.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 17))
remote:          Downloading https://files.pythonhosted.org/packages/ae/25/0c8f08c9d3c93192cd286594f1e87b17bab496fb9082c2a69e17051b91fd/whitenoise-5.0.1-py2.py3-none-any.whl
remote:        Collecting xlrd==1.2.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 18))
remote:          Downloading https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl (103kB)
remote:        Collecting zipp==0.6.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl
remote:        Collecting python-docx (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/e4/83/c66a1934ed5ed8ab1dbb9931f1779079f8bca0f6bbc5793c06c4b5e7d671/python-docx-0.8.10.tar.gz (5.5MB)
remote:        Collecting pymupdf (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 21))
remote:          Downloading https://files.pythonhosted.org/packages/3d/6a/5b4d4f1964a0802f8f2514fcd1f8d53c7f1e74a55765f99df1cf482bbbe8/PyMuPDF-1.16.10.tar.gz (175kB)
remote:        Collecting beautifulsoup4 (from bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/cb/a1/c698cf319e9cfed6b17376281bd0efc6bfc8465698f54170ef60a485ab5d/beautifulsoup4-4.8.2-py3-none-any.whl (106kB)
remote:        Collecting pytz (from Django==2.1.11->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
remote:        Collecting dj-database-url>=0.5.0 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote:        Collecting psycopg2 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
remote:        Collecting requests (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
remote:        Collecting simplejson (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/98/87/a7b98aa9256c8843f92878966dc3d8d914c14aad97e2c5ce4798d5743e07/simplejson-3.17.0.tar.gz (83kB)
remote:        Collecting numpy (from imageio==2.6.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/62/20/4d43e141b5bc426ba38274933ef8e76e85c7adea2c321ecf9ebf7421cedf/numpy-1.18.1-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)
remote:        Collecting python-dateutil>=2.6.1 (from pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
remote:        Collecting matplotlib!=3.0.0,>=2.0.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/7e/07/4b361d6d0f4e08942575f83a11d33f36897e1aae4279046606dd1808778a/matplotlib-3.1.3-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
remote:        Collecting networkx>=2.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/41/8f/dd6a8e85946def36e4f2c69c84219af0fa5e832b018c970e92f2ad337e45/networkx-2.4-py3-none-any.whl (1.6MB)
remote:        Collecting PyWavelets>=0.4.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/59/bb/d2b85265ec9fa3c1922210c9393d4cdf7075cc87cce6fe671d7455f80fbc/PyWavelets-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (4.4MB)
remote:        Collecting scipy>=0.19.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1MB)
remote:        Collecting more-itertools (from zipp==0.6.0->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/72/96/4297306cc270eef1e3461da034a3bebe7c84eff052326b130824e98fc3fb/more_itertools-8.2.0-py3-none-any.whl (43kB)
remote:        Collecting lxml>=2.3.2 (from python-docx->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/dd/ba/a0e6866057fc0bbd17192925c1d63a3b85cf522965de9bc02364d08e5b84/lxml-4.5.0-cp36-cp36m-manylinux1_x86_64.whl (5.8MB)
remote:        Collecting soupsieve>=1.2 (from beautifulsoup4->bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/81/94/03c0f04471fc245d08d0a99f7946ac228ca98da4fa75796c507f61e688c2/soupsieve-1.9.5-py2.py3-none-any.whl
remote:        Collecting certifi>=2017.4.17 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
remote:        Collecting chardet<3.1.0,>=3.0.2 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting idna<2.9,>=2.5 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
remote:        Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
remote:        Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
remote:        Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
remote:        Collecting cycler>=0.10 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
remote:        Collecting kiwisolver>=1.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f8/a1/5742b56282449b1c0968197f63eae486eca2c35dcd334bab75ad524e0de1/kiwisolver-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (90kB)
remote:        Collecting decorator>=4.3.0 (from networkx>=2.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/8f/b7/f329cfdc75f3d28d12c65980e4469e2fa373f1953f5df6e370e84ea2e875/decorator-4.4.1-py2.py3-none-any.whl
remote:        Installing collected packages: soupsieve, beautifulsoup4, bs4, pytz, Django, dj-database-url, whitenoise, psycopg2, django-heroku, django-widget-tweaks, certifi, chardet, idna, urllib3, requests, simplejson, forex-python, gunicorn, numpy, Pillow, imageio, img2pdf, imutils, opencv-python-headless, six, python-dateutil, pandas, Pygments, pypandoc, PyPDF2, pyparsing, cycler, kiwisolver, matplotlib, decorator, networkx, PyWavelets, scipy, scikit-image, xlrd, more-itertools, zipp, lxml, python-docx, pymupdf
remote:          Running setup.py install for bs4: started
remote:            Running setup.py install for bs4: finished with status 'done'
remote:          Running setup.py install for psycopg2: started
remote:            Running setup.py install for psycopg2: finished with status 'done'
remote:          Running setup.py install for simplejson: started
remote:            Running setup.py install for simplejson: finished with status 'done'
remote:          Running setup.py install for forex-python: started
remote:            Running setup.py install for forex-python: finished with status 'done'
remote:          Running setup.py install for img2pdf: started
remote:            Running setup.py install for img2pdf: finished with status 'done'
remote:          Running setup.py install for imutils: started
remote:            Running setup.py install for imutils: finished with status 'done'
remote:          Running setup.py install for pypandoc: started
remote:            Running setup.py install for pypandoc: finished with status 'done'
remote:          Running setup.py install for PyPDF2: started
remote:            Running setup.py install for PyPDF2: finished with status 'done'
remote:          Running setup.py install for python-docx: started
remote:            Running setup.py install for python-docx: finished with status 'done'
remote:          Running setup.py install for pymupdf: started
remote:            Running setup.py install for pymupdf: finished with status 'error'
remote:            Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile:
remote:            running install
remote:            running build
remote:            running build_py
remote:            creating build
remote:            creating build/lib.linux-x86_64-3.6
remote:            creating build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__init__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/fitz.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/utils.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__main__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            running build_ext
remote:            building 'fitz._fitz' extension
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/fitz
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -I/app/.heroku/python/include/python3.6m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.6/fitz/fitz_wrap.o
remote:            fitz/fitz_wrap.c:2732:10: fatal error: fitz.h: No such file or directory
remote:             #include <fitz.h>
remote:                      ^~~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:
remote:            ----------------------------------------
remote:        Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-205xyxft/pymupdf/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to compare-tool.
remote:
To https://git.heroku.com/compare-tool.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/compare-tool.git'

`


来源: stackexchange

问:
Why does my Heroku Discord bot crash after it can't connect to a port?
I'm trying to make a discord bot that runs 24/7 using Heroku. Everything is good, except for the fact that the bot crashes after 60 seconds.

The error output tells me this:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I looked for solutions on the internet, and I found quite a few. However, none of them worked.

Here's my main file's code:

```<code>const Discord = require('discord.js')
const {prefix, token} = require('./config.json')
const client = new Discord.Client()

// Login
client.login(token)

client.once('ready', () => {
    console.log('Back online')
    client.user.setActivity(' channel', {type: 'LISTENING'})
})

client.on('message', message => {
    if (message.author.bot) {
        return;
    }

    if (message.content.toLowerCase() === 'hello') {
        message.channel.send('Hey!')
    }
})
</code>```

答:
You've most likely assigned your bot to run on a web service in your Procfile. The Heroku Procfile is a file that stores information about what processes Heroku should run. If you set your Procfile to run a web service, Heroku expects you to bind to the required port (using process.env.PORT) once it launched. If it didn't then Heroku will assume that your program failed to start and will restart it.

As of now, your Procfile most likely looks like this:

```<code>web: node index.js
</code>```

This tells Heroku to run your program in a web dyno. However, if you don't bind to an HTTP port with a Node.js service like Express, Heroku will crash your program. To fix this, change web to worker.

```<code>worker: node index.js
</code>```

Note that by changing your Procfile to use worker, your free dyno hours (if you are running on a free dyno) will continue decreasing 24/7, and you'll be using up around 700 hours per month. If you registered your credit card, the limit is set to 1000 hours per month and you don't have to worry. Otherwise, you have to upgrade your dyno to a Hobby dyno to keep your bot running the entire month.

EDIT: Though this wasn't the accepted answer, I still have to clarify that sometimes Heroku doesn't read the Procfile settings. In that case, you should run these commands in the folder where your project is:

```<code>heroku ps:scale web=0
heroku ps:scale worker=1
</code>```

This will force Heroku to use the worker dyno defined in your Procfile. Hope this helps.

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to make a discord bot that runs 24/7 using Heroku. Everything is good, except for the fact that the bot crashes after 60 seconds.

The error output tells me this:

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

I looked for solutions on the internet, and I found quite a few. However, none of them worked.

Here's my main file's code:

const Discord = require('discord.js')
const {prefix, token} = require('./config.json')
const client = new Discord.Client()

// Login
client.login(token)

client.once('ready', () => {
    console.log('Back online')
    client.user.setActivity(' channel', {type: 'LISTENING'})
})

client.on('message', message => {
    if (message.author.bot) {
        return;
    }

    if (message.content.toLowerCase() === 'hello') {
        message.channel.send('Hey!')
    }
})

Body:
You've most likely assigned your bot to run on a web service in your Procfile. The Heroku Procfile is a file that stores information about what processes Heroku should run. If you set your Procfile to run a web service, Heroku expects you to bind to the required port (using process.env.PORT) once it launched. If it didn't then Heroku will assume that your program failed to start and will restart it.

As of now, your Procfile most likely looks like this:

web: node index.js

This tells Heroku to run your program in a web dyno. However, if you don't bind to an HTTP port with a Node.js service like Express, Heroku will crash your program. To fix this, change web to worker.

worker: node index.js

Note that by changing your Procfile to use worker, your free dyno hours (if you are running on a free dyno) will continue decreasing 24/7, and you'll be using up around 700 hours per month. If you registered your credit card, the limit is set to 1000 hours per month and you don't have to worry. Otherwise, you have to upgrade your dyno to a Hobby dyno to keep your bot running the entire month.

EDIT: Though this wasn't the accepted answer, I still have to clarify that sometimes Heroku doesn't read the Procfile settings. In that case, you should run these commands in the folder where your project is:

heroku ps:scale web=0
heroku ps:scale worker=1

This will force Heroku to use the worker dyno defined in your Procfile. Hope this helps.


问:
extract characters from second occurrence of dash in a string
I have a string "apple-rose-orange-21-X-84"; I need to extract the string after the second occurrence of "-" using shell script.

The answer should be orange-21-X-84.

How would I do this in shell script, I have tried several ways, couldn't find an answer.

答:
You could use cut command:

$ cut -d- -f3- <<<'apple-rose-orange-21-X-84'
orange-21-X-84
```

-d- sets the dash as cut's delimiter. -f3- selects from the 3rd to last field. <<< makes a here-string. For a more detailed explanation see man cut and man bash.

Body:
You could use cut command:

$ cut -d- -f3- <<<'apple-rose-orange-21-X-84'
orange-21-X-84

-d- sets the dash as cut's delimiter. -f3- selects from the 3rd to last field. <<< makes a here-string. For a more detailed explanation see man cut and man bash.


问:
Hamburger icon not showing on iOS developed by Prism for Xamarin.Forms
Below is my XAML page for my MasterDetailPage:

```<code><MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
             mc:Ignorable="d"
             x:Class="JapaneseLearnPrism.Views.MenuPage">
    <MasterDetailPage.Master>
        <NavigationPage Title="Menu" Icon="ic_hamburger.png">
            <x:Arguments>
                <ContentPage Title="{Binding Title}">
                    <!--Content for my menus here.-->
                </ContentPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Master>
</MasterDetailPage>
</code>```

And this is how I set up the Page Path for Prism:

protected override async void OnInitialized()
{
    InitializeComponent();
            Xamarin.Forms.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize);

    // await NavigationService.NavigateAsync("NavigationPage/MainPage");
    await NavigationService.NavigateAsync(nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(Views.MainPage));
}
```

This is works fine for the MD page function. And the hamburger icon is correctly showing in Android but not iOS. I am wondering why. I searched online everyone but actually nothing solved.
Hope be able to get the answer here.

Thanks.

答:
Use IconImageSource inside MasterDetailPage to display HamburgerIcon as far as Android is concern it uses it's default hamburger Icon that's why it is showing in Android and not in iOS.</p>

```<code><MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
             mc:Ignorable="d"
             IconImageSource="ic_hamburger.png"
             x:Class="JapaneseLearnPrism.Views.MenuPage">

</code>```

Body:
Below is my XAML page for my MasterDetailPage:

<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
             mc:Ignorable="d"
             x:Class="JapaneseLearnPrism.Views.MenuPage">
    <MasterDetailPage.Master>
        <NavigationPage Title="Menu" Icon="ic_hamburger.png">
            <x:Arguments>
                <ContentPage Title="{Binding Title}">

                </ContentPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Master>
</MasterDetailPage>

And this is how I set up the Page Path for Prism:

protected override async void OnInitialized()
{
    InitializeComponent();
            Xamarin.Forms.PlatformConfiguration.AndroidSpecific.Application.SetWindowSoftInputModeAdjust(this, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust.Resize);

    // await NavigationService.NavigateAsync("NavigationPage/MainPage");
    await NavigationService.NavigateAsync(nameof(MenuPage) + "/" + nameof(NavigationPage) + "/" + nameof(Views.MainPage));
}

This is works fine for the MD page function. And the hamburger icon is correctly showing in Android but not iOS. I am wondering why. I searched online everyone but actually nothing solved.
Hope be able to get the answer here.

Thanks.

Body:
Use IconImageSource inside MasterDetailPage to display HamburgerIcon as far as Android is concern it uses it's default hamburger Icon that's why it is showing in Android and not in iOS.

<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:b="clr-namespace:Prism.Behaviors;assembly=Prism.Forms"
             mc:Ignorable="d"
             IconImageSource="ic_hamburger.png"
             x:Class="JapaneseLearnPrism.Views.MenuPage">


问:
pivot_wider issue "Values in `values_from` are not uniquely identified; output will contain list-cols"
My data looks like this:

```<code># A tibble: 6 x 4
  name          val time          x1
  <chr>       <dbl> <date>     <dbl>
1 C Farolillo     7 2016-04-20  51.5
2 C Farolillo     3 2016-04-21  56.3
3 C Farolillo     7 2016-04-22  56.3
4 C Farolillo    13 2016-04-23  57.9
5 C Farolillo     7 2016-04-24  58.7
6 C Farolillo     9 2016-04-25  59.0
</code>```

I am trying to use the pivot_wider function to expand out the data based on the name column. I use the following code:

```<code>yy <- d %>%
  pivot_wider(., names_from = name, values_from = val)
</code>```

Which gives me the following warning message:

```<code>Warning message:
Values in `val` are not uniquely identified; output will contain list-cols.
* Use `values_fn = list(val = list)` to suppress this warning.
* Use `values_fn = list(val = length)` to identify where the duplicates arise
* Use `values_fn = list(val = summary_fun)` to summarise duplicates
</code>```

The output looks like:

```<code>       time       x1        out1    out2
    2016-04-20  51.50000    <dbl>   <dbl>
2   2016-04-21  56.34615    <dbl>   <dbl>
3   2016-04-22  56.30000    <dbl>   <dbl>
4   2016-04-23  57.85714    <dbl>   <dbl>
5   2016-04-24  58.70968    <dbl>   <dbl>
6   2016-04-25  58.96774    <dbl>   <dbl>
</code>```

I know that here mentions the issue and to resolve it they suggest using summary statistics. However I have time series data and thus do not want to use summary statistics since each day has a single value (and not multiple values).

I know the problem is because the val column has duplicates (i.e. in the above example 7 occurs 3 times.

Any suggestions on how to pivot_wider and overcome this issue?

Data:

```<code>    d <- structure(list(name = c("C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica"), val = c(7, 3, 7, 13, 7,
9, 20, 19, 4, 5, 5, 2, 6, 6, 16, 13, 7, 6, 3, 3, 6, 10, 5, 3,
5, 3, 4, 4, 10, 11, 4, 13, 8, 2, 8, 10, 3, 10, 14, 4, 2, 4, 6,
6, 8, 8, 3, 3, 13, 10, 13, 32, 25, 31, 34, 26, 33, 35, 43, 22,
22, 21, 10, 33, 33, 48, 47, 27, 23, 11, 13, 25, 31, 20, 16, 10,
9, 23, 11, 23, 26, 16, 34, 17, 4, 24, 21, 10, 26, 32, 10, 5,
9, 19, 14, 27, 27, 10, 8, 28, 32, 25), time = structure(c(16911,
16912, 16913, 16914, 16915, 16916, 16917, 16918, 16919, 16920,
16921, 16922, 16923, 16923, 16924, 16925, 16926, 16927, 16928,
16929, 16930, 16931, 16932, 16933, 16934, 16935, 16936, 16937,
16938, 16939, 16940, 16941, 16942, 16943, 16944, 16945, 16946,
16947, 16948, 16949, 16950, 16951, 16952, 16953, 16954, 16955,
16956, 16957, 16958, 16959, 16960, 16911, 16912, 16913, 16914,
16915, 16916, 16917, 16918, 16919, 16920, 16921, 16922, 16923,
16923, 16924, 16925, 16926, 16927, 16928, 16929, 16930, 16931,
16932, 16933, 16934, 16935, 16936, 16937, 16938, 16939, 16940,
16941, 16942, 16943, 16944, 16945, 16946, 16947, 16948, 16949,
16950, 16951, 16952, 16953, 16954, 16955, 16956, 16957, 16958,
16959, 16960), class = "Date"), x1 = c(51.5, 56.3461538461538,
56.3, 57.8571428571429, 58.7096774193548, 58.9677419354839, 64.4615384615385,
61.9310344827586, 60.3214285714286, 59.4137931034483, 59.5806451612903,
57.3448275862069, 64.0333333333333, 64.0333333333333, 70.15625,
71.3636363636364, 62.8125, 56.4375, 56.4516129032258, 51.741935483871,
52.84375, 53.09375, 52.969696969697, 54, 54.3870967741936, 60.3870967741936,
64.4516129032258, 66.2903225806452, 68.2333333333333, 69.7741935483871,
70.5806451612903, 73.8275862068966, 72.8181818181818, 64.6764705882353,
64.4838709677419, 68.7741935483871, 62.1764705882353, 68.969696969697,
70.1935483870968, 59.6774193548387, 59.9677419354839, 63.125,
67.5882352941177, 71.4705882352941, 73.8529411764706, 76.1935483870968,
72.6451612903226, 76.0645161290323, 76.4193548387097, 81.7741935483871,
85.0645161290323, 51.5, 56.3461538461538, 56.3, 57.8571428571429,
58.7096774193548, 58.9677419354839, 64.4615384615385, 61.9310344827586,
60.3214285714286, 59.4137931034483, 59.5806451612903, 57.3448275862069,
64.0333333333333, 64.0333333333333, 70.15625, 71.3636363636364,
62.8125, 56.4375, 56.4516129032258, 51.741935483871, 52.84375,
53.09375, 52.969696969697, 54, 54.3870967741936, 60.3870967741936,
64.4516129032258, 66.2903225806452, 68.2333333333333, 69.7741935483871,
70.5806451612903, 73.8275862068966, 72.8181818181818, 64.6764705882353,
64.4838709677419, 68.7741935483871, 62.1764705882353, 68.969696969697,
70.1935483870968, 59.6774193548387, 59.9677419354839, 63.125,
67.5882352941177, 71.4705882352941, 73.8529411764706, 76.1935483870968,
72.6451612903226, 76.0645161290323, 76.4193548387097, 81.7741935483871,
85.0645161290323)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-102L))
</code>```

答:
Typically the error

```<code>Warning message:
Values in `val` are not uniquely identified; output will contain list-cols.
</code>```

is most often caused by duplicate rows in the data (after excluding the val column), and not duplicates in the val column.

```<code>which(duplicated(d))
# [1] 14 65
</code>```

OP's data seems to have two duplicate rows which is causing this issue. Removing the duplicate rows also gets rid of the error.

```<code>yy <- d %>% distinct() %>% pivot_wider(., names_from = name, values_from = val)
yy
</code>```

```<code># A tibble: 50 x 4
   time          x1 `C Farolillo` `Plaza Eliptica`
   <date>     <dbl>         <dbl>            <dbl>
 1 2016-04-20  51.5             7               32
 2 2016-04-21  56.3             3               25
 3 2016-04-22  56.3             7               31
 4 2016-04-23  57.9            13               34
 5 2016-04-24  58.7             7               26
 6 2016-04-25  59.0             9               33
 7 2016-04-26  64.5            20               35
 8 2016-04-27  61.9            19               43
 9 2016-04-28  60.3             4               22
10 2016-04-29  59.4             5               22
# ... with 40 more rows
</code>```

Body:
My data looks like this:

# A tibble: 6 x 4
  name          val time          x1
  <chr>       <dbl> <date>     <dbl>
1 C Farolillo     7 2016-04-20  51.5
2 C Farolillo     3 2016-04-21  56.3
3 C Farolillo     7 2016-04-22  56.3
4 C Farolillo    13 2016-04-23  57.9
5 C Farolillo     7 2016-04-24  58.7
6 C Farolillo     9 2016-04-25  59.0

I am trying to use the pivot_wider function to expand out the data based on the name column. I use the following code:

yy <- d %>%
  pivot_wider(., names_from = name, values_from = val)

Which gives me the following warning message:

Warning message:
Values in `val` are not uniquely identified; output will contain list-cols.
* Use `values_fn = list(val = list)` to suppress this warning.
* Use `values_fn = list(val = length)` to identify where the duplicates arise
* Use `values_fn = list(val = summary_fun)` to summarise duplicates

The output looks like:

       time       x1        out1    out2
    2016-04-20  51.50000    <dbl>   <dbl>
2   2016-04-21  56.34615    <dbl>   <dbl>
3   2016-04-22  56.30000    <dbl>   <dbl>
4   2016-04-23  57.85714    <dbl>   <dbl>
5   2016-04-24  58.70968    <dbl>   <dbl>
6   2016-04-25  58.96774    <dbl>   <dbl>

I know that here mentions the issue and to resolve it they suggest using summary statistics. However I have time series data and thus do not want to use summary statistics since each day has a single value (and not multiple values).

I know the problem is because the val column has duplicates (i.e. in the above example 7 occurs 3 times.

Any suggestions on how to pivot_wider and overcome this issue?

Data:

    d <- structure(list(name = c("C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo", "C Farolillo",
"C Farolillo", "C Farolillo", "C Farolillo", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica", "Plaza Eliptica",
"Plaza Eliptica", "Plaza Eliptica"), val = c(7, 3, 7, 13, 7,
9, 20, 19, 4, 5, 5, 2, 6, 6, 16, 13, 7, 6, 3, 3, 6, 10, 5, 3,
5, 3, 4, 4, 10, 11, 4, 13, 8, 2, 8, 10, 3, 10, 14, 4, 2, 4, 6,
6, 8, 8, 3, 3, 13, 10, 13, 32, 25, 31, 34, 26, 33, 35, 43, 22,
22, 21, 10, 33, 33, 48, 47, 27, 23, 11, 13, 25, 31, 20, 16, 10,
9, 23, 11, 23, 26, 16, 34, 17, 4, 24, 21, 10, 26, 32, 10, 5,
9, 19, 14, 27, 27, 10, 8, 28, 32, 25), time = structure(c(16911,
16912, 16913, 16914, 16915, 16916, 16917, 16918, 16919, 16920,
16921, 16922, 16923, 16923, 16924, 16925, 16926, 16927, 16928,
16929, 16930, 16931, 16932, 16933, 16934, 16935, 16936, 16937,
16938, 16939, 16940, 16941, 16942, 16943, 16944, 16945, 16946,
16947, 16948, 16949, 16950, 16951, 16952, 16953, 16954, 16955,
16956, 16957, 16958, 16959, 16960, 16911, 16912, 16913, 16914,
16915, 16916, 16917, 16918, 16919, 16920, 16921, 16922, 16923,
16923, 16924, 16925, 16926, 16927, 16928, 16929, 16930, 16931,
16932, 16933, 16934, 16935, 16936, 16937, 16938, 16939, 16940,
16941, 16942, 16943, 16944, 16945, 16946, 16947, 16948, 16949,
16950, 16951, 16952, 16953, 16954, 16955, 16956, 16957, 16958,
16959, 16960), class = "Date"), x1 = c(51.5, 56.3461538461538,
56.3, 57.8571428571429, 58.7096774193548, 58.9677419354839, 64.4615384615385,
61.9310344827586, 60.3214285714286, 59.4137931034483, 59.5806451612903,
57.3448275862069, 64.0333333333333, 64.0333333333333, 70.15625,
71.3636363636364, 62.8125, 56.4375, 56.4516129032258, 51.741935483871,
52.84375, 53.09375, 52.969696969697, 54, 54.3870967741936, 60.3870967741936,
64.4516129032258, 66.2903225806452, 68.2333333333333, 69.7741935483871,
70.5806451612903, 73.8275862068966, 72.8181818181818, 64.6764705882353,
64.4838709677419, 68.7741935483871, 62.1764705882353, 68.969696969697,
70.1935483870968, 59.6774193548387, 59.9677419354839, 63.125,
67.5882352941177, 71.4705882352941, 73.8529411764706, 76.1935483870968,
72.6451612903226, 76.0645161290323, 76.4193548387097, 81.7741935483871,
85.0645161290323, 51.5, 56.3461538461538, 56.3, 57.8571428571429,
58.7096774193548, 58.9677419354839, 64.4615384615385, 61.9310344827586,
60.3214285714286, 59.4137931034483, 59.5806451612903, 57.3448275862069,
64.0333333333333, 64.0333333333333, 70.15625, 71.3636363636364,
62.8125, 56.4375, 56.4516129032258, 51.741935483871, 52.84375,
53.09375, 52.969696969697, 54, 54.3870967741936, 60.3870967741936,
64.4516129032258, 66.2903225806452, 68.2333333333333, 69.7741935483871,
70.5806451612903, 73.8275862068966, 72.8181818181818, 64.6764705882353,
64.4838709677419, 68.7741935483871, 62.1764705882353, 68.969696969697,
70.1935483870968, 59.6774193548387, 59.9677419354839, 63.125,
67.5882352941177, 71.4705882352941, 73.8529411764706, 76.1935483870968,
72.6451612903226, 76.0645161290323, 76.4193548387097, 81.7741935483871,
85.0645161290323)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-102L))

Body:
Typically the error

Warning message:
Values in `val` are not uniquely identified; output will contain list-cols.

is most often caused by duplicate rows in the data (after excluding the val column), and not duplicates in the val column.

which(duplicated(d))
# [1] 14 65

OP's data seems to have two duplicate rows which is causing this issue. Removing the duplicate rows also gets rid of the error.

yy <- d %>% distinct() %>% pivot_wider(., names_from = name, values_from = val)
yy

# A tibble: 50 x 4
   time          x1 `C Farolillo` `Plaza Eliptica`
   <date>     <dbl>         <dbl>            <dbl>
 1 2016-04-20  51.5             7               32
 2 2016-04-21  56.3             3               25
 3 2016-04-22  56.3             7               31
 4 2016-04-23  57.9            13               34
 5 2016-04-24  58.7             7               26
 6 2016-04-25  59.0             9               33
 7 2016-04-26  64.5            20               35
 8 2016-04-27  61.9            19               43
 9 2016-04-28  60.3             4               22
10 2016-04-29  59.4             5               22
# ... with 40 more rows


问:
How to change link Navbar color while scrolling in React or Gatsby?
While scrolling, I want to change the color Links depending on Id. how can i do that?

Example:

```<code>     <div>
          <nav>
            <div className="bg-mainColor h-16 flex justify-between">
              <div className="text-white">Navbar</div>

              <div>
                <Link to="/" className="text-white">
                  Home
                </Link>
                <Link to="#first" className="text-white">
                  Features
                </Link>
                <a href="#" className="text-white">
                  Courses
                </a>
              </div>
            </div>
          </nav>

          <div className="min-h-screen" id="feature">
            Features
          </div>

          <div className="min-h-screen" id="course">
            Courses
          </div>

        </div>
</code>```

Check this picture to understand me more

答:
you must add an Id to your link and add an event listener on your componentDidMount :

```<code>componentDidMount() {
  document.addEventListener('scroll' , this.handleScroll)
}
</code>```

and your handleScroll is like :

```<code>handleScroll  = (event) => {
  //handle your event base on scroll in pixels or what ever for example :
  if(window.scrollY > 100) {
     let aEl = document.getElementById('YOUR_LINK_ID');
     aEl.setAttribute("style" , "color : red")

  }
}
</code>```

and dont forget to removeEventListener on ComponentWillUnMount :

```<code>componentWillUnMount() {
  document.removeEventListener('scroll',this.handleScroll);
}

</code>```

Body:
While scrolling, I want to change the color Links depending on Id. how can i do that?

Example:

Navbar

                <Link to="/" className="text-white">
                  Home
                </Link>
                <Link to="#first" className="text-white">
                  Features
                </Link>

                  Courses

            Features

            Courses

Check this picture to understand me more

Body:
you must add an Id to your link and add an event listener on your componentDidMount :

componentDidMount() {
  document.addEventListener('scroll' , this.handleScroll)
}

and your handleScroll is like :

handleScroll  = (event) => {
  //handle your event base on scroll in pixels or what ever for example :
  if(window.scrollY > 100) {
     let aEl = document.getElementById('YOUR_LINK_ID');
     aEl.setAttribute("style" , "color : red")

  }
}

and dont forget to removeEventListener on ComponentWillUnMount :

componentWillUnMount() {
  document.removeEventListener('scroll',this.handleScroll);
}


问:
Button click next array sentence (Javascript)
I have a list of array that I want to show after each question is answered. It's gonna be like a never have I ever game I am build for building my skills. This ain't working at all why?

var question = new Array()

var intquestion_index = 0;

function displayQuestion() {
  if (intquestion_index == question.length) intquestion_index = 0;
  document.getElementById('questions').innerHTML;
  intquestion_index++;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="questions" id="questions">-</div>
<div class="answer">
  <button type="button" class="btn btn-dark" id="btn-1" onclick="displayQuestion();">Hell yeah!</button>
  <button type="button" class="btn btn-dark" id="btn-2" onclick="displayQuestion();">Never ever ever</button>
  <button type="button" class="btn btn-dark" id="btn-3" onclick="displayQuestion();">Maybe</button>
</div></code>```

答:
This should do what you expect: move to next question on clicking one of the answer(button)

var question = new Array();
question[0] = "question 1";
question[1] = "question 2";
question[2] = "question 3";
question[3] = "question 4";
// Below line will show first question on page load
document.getElementById('questions').innerHTML = question[0];

// question at 0 is shown, so start index with 1
var question_index =1;

function displayQuestion() {
  if (question_index == question.length)
  {
   question_index = 0;
  }
  document.getElementById('questions').innerHTML = question[question_index];
  question_index++;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="questions" id="questions">-</div>
<div class="answer">
  <button type="button" class="btn btn-dark" id="btn-1" onclick="displayQuestion();">Hell yeah!</button>
  <button type="button" class="btn btn-dark" id="btn-2" onclick="displayQuestion();">Never ever ever</button>
  <button type="button" class="btn btn-dark" id="btn-3" onclick="displayQuestion();">Maybe</button>
</div></code>```

Body:
I have a list of array that I want to show after each question is answered. It's gonna be like a never have I ever game I am build for building my skills. This ain't working at all why?

var question = new Array()

var intquestion_index = 0;

function displayQuestion() {
  if (intquestion_index == question.length) intquestion_index = 0;
  document.getElementById('questions').innerHTML;
  intquestion_index++;
}

-

  <button type="button" class="btn btn-dark" id="btn-1" onclick="displayQuestion();">Hell yeah!</button>
  <button type="button" class="btn btn-dark" id="btn-2" onclick="displayQuestion();">Never ever ever</button>
  <button type="button" class="btn btn-dark" id="btn-3" onclick="displayQuestion();">Maybe</button>

Body:
This should do what you expect: move to next question on clicking one of the answer(button)

var question = new Array();
question[0] = "question 1";
question[1] = "question 2";
question[2] = "question 3";
question[3] = "question 4";
// Below line will show first question on page load
document.getElementById('questions').innerHTML = question[0];

// question at 0 is shown, so start index with 1
var question_index =1;

function displayQuestion() {
  if (question_index == question.length)
  {
   question_index = 0;
  }
  document.getElementById('questions').innerHTML = question[question_index];
  question_index++;
}

<div class="questions" id="questions">-</div>
<div class="answer">
  <button type="button" class="btn btn-dark" id="btn-1" onclick="displayQuestion();">Hell yeah!</button>
  <button type="button" class="btn btn-dark" id="btn-2" onclick="displayQuestion();">Never ever ever</button>
  <button type="button" class="btn btn-dark" id="btn-3" onclick="displayQuestion();">Maybe</button>
</div>


问:
How to deal with merge/pull in git
I have to use different computers. I updated file A, B and other files in one and B, C and other files in another.

Updates in file B are different part of code.  I have committed in both.
I pushed A and B to the github.

Questions:

Now what should I do in another?

Should I just pull? Or should I push first?

If I push, will file A be overwritten?

If I pull, will file C be overwritten?

What kind of process do I need to take?

What do I need to do with file B which has different version? Can I merge them?

答: Pull -> rebase -> push: http://learn.github.com/p/rebasing.html</p>

ContentLicense: CC BY-SA 3.0

Title: How to deal with merge/pull in git


问:
Query on Ali baba Cloud Billing API BOA
I was trying to get some data by using one of the api call QueryInstanceBill

The resulted JSON seems to be long and there is no date column to filter on how i got those many records.

Could someone here help me out

答:
QueryInstanceBill API returns data for billing cycle which is usually for a month (YYYY-MM)

If you want data for a particular date then in request parameter provide the value for field "BillingDate" in format: YYYY-MM-DD
and the value for field "Granularity" should be "DAILY"

Check out the documentation:

https://www.alibabacloud.com/help/doc-detail/100400.htm

Also, you can use OpenAPI Explorer, I have provided BillingCycle as "2019-10", BillingDate as "2019-10-15" and Granularity as "DAILY":

https://api.aliyun.com/#/?product=BssOpenApi&version=2017-12-14&api=QueryInstanceBill&params={%22RegionId%22:%22cn-hangzhou%22,%22Granularity%22:%22DAILY%22,%22BillingCycle%22:%222019-10%22,%22BillingDate%22:%222019-10-15%22}&tab=DEMO&lang=JAVA

Title: Query on Ali baba Cloud Billing API BOA


问:
How can I construct a unique_ptr pointing to a vector with single element conveniently?
I would like to construct a unique_ptr holding a vector<string>, which contains single element only. Is it possible to do this in single line of code?
I try this approach:

```<code>auto values = make_unique<vector<string>>({value});
</code>```

But compiler (clang++) complains:

```<code>No matching function for call to 'make_unique' candidate template ignored:
substitution failure [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >]: no type named '__unique_array_unknown_bound' in 'std::__1::__unique_if<st... candidate template ignored: substitution failure [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >]: no type named '__unique_array_known_bound' in 'std::__1::__unique_if<std:... candidate function [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >, _Args = <>] not viable: requires 0 arguments, but 1 was provided

</code>```

I don't understand why it doesn't work since vector apparently accepts using initializer_list for construction.

```<code>string value = ...;
auto values = vector<string>({value}); // this works
</code>```

Is creating a unique_ptr<vector<string>> and calling its push_back the only viable approach for constructing such a unique_ptr?

```<code>auto values = make_unique<vector<string>>();
values->push_back(value);
</code>```

More broadly, if I have a fixed number of elements (for example, 3 elements), and would like to build a unique_ptr holding a vector with these elements, what is the idiomatic way to do it?

答:
{...} appearing in a function call is not an initializer list (unless the function explicitly asks for a std::initializer_list); it's only an initializer list if it's being used to directly initialize something (e.g. on the right-hand-side of an assignment, or in a range-for loop).

If you really want to pass an initializer list, you can do so explicitly:

auto values = std::make_unique<std::vector<std::string>>(
  std::initializer_list<std::string>{ value });
```

<p>You could also just construct a temporary vector and pass that in instead:</p>

<pre class="lang-cpp prettyprint-override"><code>auto values = std::make_unique<std::vector<std::string>>(std::vector<std::string>{ value });
</code>```

Or using C++17 CTAD:

auto values = std::make_unique<std::vector<std::string>>(std::vector{ value });
```

<p>This will generalise to any number of fixed elements. If you just want a vector with three elements but don't care about the values, you can use <code>std::vector</code>'s "count" constructor:</p>

<pre class="lang-cpp prettyprint-override"><code>auto values = std::make_unique<std::vector<std::string>>(3);
// values contains three empty strings
</code>```

Body:
I would like to construct a unique_ptr holding a vector<string>, which contains single element only. Is it possible to do this in single line of code?
I try this approach:

auto values = make_unique<vector<string>>({value});

But compiler (clang++) complains:

No matching function for call to 'make_unique' candidate template ignored:
substitution failure [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >]: no type named '__unique_array_unknown_bound' in 'std::__1::__unique_if<st... candidate template ignored: substitution failure [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >]: no type named '__unique_array_known_bound' in 'std::__1::__unique_if<std:... candidate function [with _Tp = std::__1::vector<std::__1::basic_string<char>, std::__1::allocator<std::__1::basic_string<char> > >, _Args = <>] not viable: requires 0 arguments, but 1 was provided

I don't understand why it doesn't work since vector apparently accepts using initializer_list for construction.

string value = ...;
auto values = vector<string>({value}); // this works

Is creating a unique_ptr<vector<string>> and calling its push_back the only viable approach for constructing such a unique_ptr?

auto values = make_unique<vector<string>>();
values->push_back(value);

More broadly, if I have a fixed number of elements (for example, 3 elements), and would like to build a unique_ptr holding a vector with these elements, what is the idiomatic way to do it?

Body:
{...} appearing in a function call is not an initializer list (unless the function explicitly asks for a std::initializer_list); it's only an initializer list if it's being used to directly initialize something (e.g. on the right-hand-side of an assignment, or in a range-for loop).

If you really want to pass an initializer list, you can do so explicitly:

auto values = std::make_unique<std::vector<std::string>>(
  std::initializer_list<std::string>{ value });

You could also just construct a temporary vector and pass that in instead:

auto values = std::make_unique<std::vector<std::string>>(std::vector<std::string>{ value });

Or using C++17 CTAD:

auto values = std::make_unique<std::vector<std::string>>(std::vector{ value });

This will generalise to any number of fixed elements. If you just want a vector with three elements but don't care about the values, you can use std::vector's "count" constructor:

auto values = std::make_unique<std::vector<std::string>>(3);
// values contains three empty strings


问:
java design problem for validations
I have the following requirement:
I have a validation system.  One of the things that I need to do is perform validations on XML files, meaning validating that tag X equals a given value.  I have more than one possible scenario, and in each scenario there is a different set of tags that need to be validated.

I don't want to repeat same code when testing same tags in different scenarios.

I'm trying to figure out a design that will solve this issue.

Any ideas?

Thanks.

答:
Erm, delegate to a shared method? Like:

```<code>void validateAppleScenario(Xml xml) {
    validateFruit(xml);
    // validate apples specific tags
}

void validateBanana(Xml xml) {
    validateFruit(xml);
    // validate banana specific tags
}

void validateFruit(Xml xml) {
    // validate tags common to all fruit
}
</code>```

Or if you prefer validators to be seperate objects, you can use subtyping:

```<code>interface Validator {
    void validate(Xml xml);
}

class FruitValidator implements Validator {
    void validate(Xml xml) {
        // validate tags common to all fruit
    }
}

class AppleValidator extends FruitValidator {
    void validate(Xml xml) {
        super.validate(xml);
        // validate tags specific to apples
    }
}
</code>```

Title: java design problem for validations

Body:
Erm, delegate to a shared method? Like:

void validateAppleScenario(Xml xml) {
    validateFruit(xml);
    // validate apples specific tags
}

void validateBanana(Xml xml) {
    validateFruit(xml);
    // validate banana specific tags
}

void validateFruit(Xml xml) {
    // validate tags common to all fruit
}

Or if you prefer validators to be seperate objects, you can use subtyping:

interface Validator {
    void validate(Xml xml);
}

class FruitValidator implements Validator {
    void validate(Xml xml) {
        // validate tags common to all fruit
    }
}

class AppleValidator extends FruitValidator {
    void validate(Xml xml) {
        super.validate(xml);
        // validate tags specific to apples
    }
}


问:
Options page not showing up
I cant see this menu names in admin menu list.
This plugin just show me Custom fields on the menu.
Whats wrong on this code ?

What I have in functions.php file

```<code>if( function_exists('acf_add_options_page') ) {

    acf_add_options_page(array(
        'page_title'    => 'Site Ayarları',
        'menu_title'    => 'Site Ayarları',
        'menu_slug'     => 'site-ayarlari',
        'capability'    => 'manage_options',
        'redirect'      => false
    ));

    acf_add_options_page(array(
        'page_title'    => 'Ana Sayfa Ayarları',
        'menu_title'    => 'Ana Sayfa Ayarları',
        'menu_slug'     => 'anasayfa-ayarlari',
        'parent_slug'   => 'site-ayarlari',
        'capability'    => 'manage_options',
        'redirect'      => false
    ));

}
</code>```

答:
You can add options page if you have ACF PRO. With only ACF you can't add options page.

And if you have ACF PRO then just paste below code in your functions.php file and try.

```<code>if( function_exists('acf_add_options_page') ) {

    acf_add_options_page();

}
</code>```

Title: Options page not showing up

Body:
I cant see this menu names in admin menu list.
This plugin just show me Custom fields on the menu.
Whats wrong on this code ?

What I have in functions.php file

if( function_exists('acf_add_options_page') ) {

    acf_add_options_page(array(
        'page_title'    => 'Site Ayarları',
        'menu_title'    => 'Site Ayarları',
        'menu_slug'     => 'site-ayarlari',
        'capability'    => 'manage_options',
        'redirect'      => false
    ));

    acf_add_options_page(array(
        'page_title'    => 'Ana Sayfa Ayarları',
        'menu_title'    => 'Ana Sayfa Ayarları',
        'menu_slug'     => 'anasayfa-ayarlari',
        'parent_slug'   => 'site-ayarlari',
        'capability'    => 'manage_options',
        'redirect'      => false
    ));

}

Body:
You can add options page if you have ACF PRO. With only ACF you can't add options page.

And if you have ACF PRO then just paste below code in your functions.php file and try.

if( function_exists('acf_add_options_page') ) {

    acf_add_options_page();

}


问:
Google people API i cant get the email addresses
```<code>        gapi.client.people.people.connections.list({
       'resourceName': 'people/me',
       'pageSize': 120,
       'personFields': 'names,phoneNumbers,emailAddresses'
     })
</code>```

<p>[i already specify emailAddresses as one of my personfields but i dont see email address in the response as shown below.this is the response in console.</p>

答: Maybe check if your scopes allow you access to email addresses and if that contact actually has an email address. I believe the API doesn't even add a field if it's empty, rather than populating a field with an empty value.</p>

Body:
        gapi.client.people.people.connections.list({
       'resourceName': 'people/me',
       'pageSize': 120,
       'personFields': 'names,phoneNumbers,emailAddresses'
     })

[i already specify emailAddresses as one of my personfields but i dont see email address in the response as shown below.this is the response in console.


问:
Manage timezone in rails multi-step form
I have a multistep form that store data in a session table. Before storing the data I make up for the time difference by creating an @offset variable that carries the timezone agent.

```<code>  @offset = DateTime.now.in_time_zone(params[:event][:time_zone]).utc_offset / 3600
  params[:event][:google_address] = current_user.google_address if params[:event][:google_address].blank?
  params[:event][:start] = DateTime.strptime(params[:event][:start], "%m/%d/%Y %l:%M %P")  - @offset.hours
  params[:event][:end] = DateTime.strptime(params[:event][:end], "%m/%d/%Y %l:%M %P") - @offset.hours
  session[:event_params].deep_merge!(params[:event]) if params[:event]
</code>```

This works well, but if the user returns to the previous steps (before saving the form), the form bring back the GMT time. I would like to re-display the time in the users time zone in the input field.

Does anybody knows the trick please ?

答:
You can store params[:event][:time_zone] in user's session once you have the data

session[:timezone] = params[:event][:time_zone]

And in previous step you can access this and display form accordingly

session[:timezone] # will nil or value

Body:
I have a multistep form that store data in a session table. Before storing the data I make up for the time difference by creating an @offset variable that carries the timezone agent.

  @offset = DateTime.now.in_time_zone(params[:event][:time_zone]).utc_offset / 3600
  params[:event][:google_address] = current_user.google_address if params[:event][:google_address].blank?
  params[:event][:start] = DateTime.strptime(params[:event][:start], "%m/%d/%Y %l:%M %P")  - @offset.hours
  params[:event][:end] = DateTime.strptime(params[:event][:end], "%m/%d/%Y %l:%M %P") - @offset.hours
  session[:event_params].deep_merge!(params[:event]) if params[:event]

This works well, but if the user returns to the previous steps (before saving the form), the form bring back the GMT time. I would like to re-display the time in the users time zone in the input field.

Does anybody knows the trick please ?


问:
React native tap on touchable opacity while TextInput is focused
I'm having a problem with React Native.

I have a TextInput, when focusing on the text input, I open a dropdown. Now, if I want to select something on the dropdown, I first have to click to lose the focus of the TextInput, and then it will capture the onPress event on the dropdown options.

I can manually for the blur when clicking on the textinput, but that way, the user won't be able to write on it.

Any solution for this? Thanks!

答:
You can use this inside inside scrollView property

```<code>keyboardShouldPersistTaps="handled" so that it can be handled.
</code>```

Hope it helps. feel free for doubts

Body:
You can use this inside inside scrollView property

keyboardShouldPersistTaps="handled" so that it can be handled.

Hope it helps. feel free for doubts


问:
Replace span's in PHP but keep content inside
I have the following string:

```<code><span style="font-size: 13px;">
   <span style="">
      <span style="">
         <span style="font-family: Roboto, sans-serif;">
            <span style="">
               Some text content
            </span>
         </span>
      </span>
   </span>
</span>
</code>```

and I want to change this string to the following using PHP:

```<code><span style="font-size: 13px;">
   <span style="font-family: Roboto, sans-serif;">
      Some text content
   </span>
</span>
</code>```

I dont have any idea, how to do that, because when I try to use str_replace to replace the  I dont know, how to replace the  and keep the content inside. My next problem is, that I dont know exactly, how much  I have in my string. I also have not only 1 of this blocks in my string.

Thanks in advance for your help, and maybe sorry for my stupid question - I'm still learning.

答:
For a more general way to modify HTML document, take a look at XSLT (Extensible Stylesheet Language Transformations). PHP has a XSLT library.

You then have an XML document with your transform rules in place:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes"/>

    <xsl:template match="*[@style and string-length(./@style) = 0]">
        <xsl:apply-templates />
    </xsl:template>

    <xsl:template match="*">
        <xsl:copy select=".">

            <xsl:copy-of select="@*" />

            <xsl:apply-templates select="*" />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>
```

<p>Then your PHP:</p>

<pre class="lang-php prettyprint-override"><code>$sourceHtml = new DOMDocument();
$sourceHtml->load('source.html');

$xsl = new DOMDocument();
$xsl->load('transform.xsl');

$xsltProcessor = new XSLTProcessor;
$xsltProcessor->importStyleSheet($xsl); // attach the xsl rules

echo $xsltProcessor->transformToXML($sourceHtml);

$transformedHtml = $xsltProcessor->transformToDoc($sourceHtml);
$transformedHtml->saveHTMLFile('transformed.html');
</code>```

XSLT is superpowerful for this kind of thing, and you can set all sorts of rules for parent/sibling relationships, and modify attributes and content accordingly.

Body:
I have the following string:

               Some text content

and I want to change this string to the following using PHP:

      Some text content

I dont have any idea, how to do that, because when I try to use str_replace to replace the  I dont know, how to replace the  and keep the content inside. My next problem is, that I dont know exactly, how much  I have in my string. I also have not only 1 of this blocks in my string.

Thanks in advance for your help, and maybe sorry for my stupid question - I'm still learning.

Body:
For a more general way to modify HTML document, take a look at XSLT (Extensible Stylesheet Language Transformations). PHP has a XSLT library.

You then have an XML document with your transform rules in place:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes"/>

    <!-- remove spans with empty styles -->
    <xsl:template match="*[@style and string-length(./@style) = 0]">
        <xsl:apply-templates />
    </xsl:template>

    <!-- catch all to copy any elements that aren't matched in other templates -->
    <xsl:template match="*">
        <xsl:copy select=".">
            <!-- copy the attributes of the element -->
            <xsl:copy-of select="@*" />
            <!-- continue applying templates to this element's children -->
            <xsl:apply-templates select="*" />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Then your PHP:

$sourceHtml = new DOMDocument();
$sourceHtml->load('source.html');

$xsl = new DOMDocument();
$xsl->load('transform.xsl');

$xsltProcessor = new XSLTProcessor;
$xsltProcessor->importStyleSheet($xsl); // attach the xsl rules

echo $xsltProcessor->transformToXML($sourceHtml);

$transformedHtml = $xsltProcessor->transformToDoc($sourceHtml);
$transformedHtml->saveHTMLFile('transformed.html');

XSLT is superpowerful for this kind of thing, and you can set all sorts of rules for parent/sibling relationships, and modify attributes and content accordingly.