Error: Unable to run code with xmlschema after build with pyinstaller - xsd

I'm new to xmlschema and pyinstaller and need some help for the error that I have encountered.
I have downloaded both xmlschema (1.9)and pyinstaller (4.7) in Python 3.6.8.
In my python script, I have added import xmlschema in order to use it.
After that, I complied my code using `pyinstaller --onefile --windowed schema_check_xsd_11.py to create an windows exe application.
Compilation OK:
D:\Project\WA_Schema\Schema_Check>pyinstaller --onefile --windowed schema_check_xsd_11.py
82 INFO: PyInstaller: 4.7
82 INFO: Python: 3.6.8
84 INFO: Platform: Windows-10-10.0.17763-SP0
90 INFO: wrote D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.spec
92 INFO: UPX is not available.
93 INFO: Extending PYTHONPATH with paths
['D:\\Project\\WA_Schema\\Schema_Check']
346 INFO: checking Analysis
361 INFO: Building because D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.py changed
362 INFO: Initializing module dependency graph...
364 INFO: Caching module graph hooks...
380 INFO: Analyzing base_library.zip ...
2806 INFO: Caching module dependency graph...
2939 INFO: running Analysis Analysis-00.toc
2941 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python36\python.exe
3006 INFO: Analyzing D:\Project\WA_Schema\Schema_Check\schema_check_xsd_11.py
4478 INFO: Processing module hooks...
4479 INFO: Loading module hook 'hook-difflib.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4481 INFO: Loading module hook 'hook-encodings.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4621 INFO: Loading module hook 'hook-heapq.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4622 INFO: Loading module hook 'hook-pickle.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4624 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4628 INFO: Loading module hook 'hook-xml.py' from 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks'...
4675 INFO: Looking for ctypes DLLs
4676 INFO: Analyzing run-time hooks ...
4678 INFO: Including run-time hook 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
4683 INFO: Including run-time hook 'c:\\python36\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
4689 INFO: Looking for dynamic libraries
4806 INFO: Looking for eggs
4806 INFO: Using Python library c:\python36\python36.dll
4807 INFO: Found binding redirects:
[]
4815 INFO: Warnings written to D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\warn-schema_check_xsd_11.txt
4855 INFO: Graph cross-reference written to D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\xref-schema_check_xsd_11.html
4862 INFO: checking PYZ
4878 INFO: Building because toc changed
4878 INFO: Building PYZ (ZlibArchive) D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\PYZ-00.pyz
5355 INFO: Building PYZ (ZlibArchive) D:\Project\WA_Schema\Schema_Check\build\schema_check_xsd_11\PYZ-00.pyz completed successfully.
5366 INFO: checking PKG
5379 INFO: Building because toc changed
5380 INFO: Building PKG (CArchive) schema_check_xsd_11.pkg
6725 INFO: Building PKG (CArchive) schema_check_xsd_11.pkg completed successfully.
6727 INFO: Bootloader c:\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
6727 INFO: checking EXE
6746 INFO: Building because toc changed
6747 INFO: Building EXE from EXE-00.toc
6758 INFO: Copying bootloader EXE to D:\Project\WA_Schema\Schema_Check\dist\schema_check_xsd_11.exe
6763 INFO: Copying icon to EXE
6764 INFO: Copying icons from ['c:\\python36\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-windowed.ico']
6769 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
6769 INFO: Writing RT_ICON 1 resource with 3752 bytes
6773 INFO: Writing RT_ICON 2 resource with 2216 bytes
6774 INFO: Writing RT_ICON 3 resource with 1384 bytes
6774 INFO: Writing RT_ICON 4 resource with 38188 bytes
6775 INFO: Writing RT_ICON 5 resource with 9640 bytes
6775 INFO: Writing RT_ICON 6 resource with 4264 bytes
6776 INFO: Writing RT_ICON 7 resource with 1128 bytes
6779 INFO: Copying 0 resources to EXE
6783 INFO: Emedding manifest in EXE
6784 INFO: Updating manifest in D:\Project\WA_Schema\Schema_Check\dist\schema_check_xsd_11.exe
6787 INFO: Updating resource type 24 name 1 language 0
6790 INFO: Appending PKG archive to EXE
8145 INFO: Building EXE from EXE-00.toc completed successfully.
Error when run windows application (schema_check_xsd_11.exe):
Traceback (most recent call last):
File "urllib\request.py", line 1474, in open_local_file
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\test\\AppData\\Local\\Temp\\_MEI169402\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "schema_check_xsd_11.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\__init__.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\dataobjects.py", line 27, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\validators\__init__.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "xmlschema\validators\schemas.py", line 2126, in <module>
File "xmlschema\validators\schemas.py", line 148, in __new__
File "xmlschema\validators\schemas.py", line 764, in create_meta_schema
File "xmlschema\validators\schemas.py", line 357, in __init__
File "xmlschema\resources.py", line 508, in __init__
File "xmlschema\resources.py", line 742, in parse
File "urllib\request.py", line 223, in urlopen
File "urllib\request.py", line 526, in open
File "urllib\request.py", line 544, in _open
File "urllib\request.py", line 504, in _call_chain
File "urllib\request.py", line 1452, in file_open
File "urllib\request.py", line 1491, in open_local_file
urllib.error.URLError: <urlopen error [WinError 3] The system cannot find the path specified: 'C:\\Users\\test\\AppData\\Local\\Temp\\_MEI169402\\xmlschema\\schemas\\XSD_1.0\\XMLSchema.xsd'>
If I remove import xmlschema from my code and re-build, I can run the window application without any error. Appreciate for any advise or help.
The installed xmlschema is located in C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.0.

Just add --add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.0;xmlschema/schemas/XSD_1.0 to your PyInstaller command.

The following files are added when build python script as a windows application with xmlschema.
pyinstaller --onefile --windowed ^
--add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XML\xml_minimal.xsd;xmlschema/schemas/XML ^
--add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\VC\XMLSchema-versioning.xsd;xmlschema/schemas/VC ^
--add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.1;xmlschema/schemas/XSD_1.1 ^
--add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XSI\XMLSchema-instance_minimal.xsd;xmlschema/schemas/XSI ^
--add-data=C:\Python36\Lib\site-packages\xmlschema\schemas\XSD_1.0;xmlschema/schemas/XSD_1.0 schema_check_xsd_11.py

Related

How to fix an attribution error when converting a python script to an .exe using Linux

Relative Linux noob here. Just trying to convert a python code into an .exe
When I run pyinstaller (1st time since install) it creates the dist file, but it is empty.
Error looks like this:
48 INFO: PyInstaller: 3.5+498e6ee058
48 INFO: Python: 3.9.9
51 INFO: Platform: Linux-5.14.0-kali4-amd64-x86_64-with-glibc2.33
61 INFO: wrote /home/kali/Py_Projects/turtles.spec
68 INFO: UPX is available.
70 INFO: Extending PYTHONPATH with paths
['/home/kali/Py_Projects', '/home/kali/Py_Projects']
70 INFO: checking Analysis
70 INFO: Building Analysis because Analysis-00.toc is non existent
70 INFO: Initializing module dependency graph...
77 INFO: Initializing module graph hooks...
79 INFO: Analyzing base_library.zip ...
3395 INFO: Processing pre-find module path hook distutils
8396 INFO: running Analysis Analysis-00.toc
8443 INFO: Caching module hooks...
8447 INFO: Analyzing /home/kali/Py_Projects/turtles.py
8577 INFO: Loading module hooks...
8577 INFO: Loading module hook "hook-distutils.py"...
8579 INFO: Loading module hook "hook-sysconfig.py"...
8587 INFO: Loading module hook "hook-lib2to3.py"...
8588 INFO: Loading module hook "hook-pydoc.py"...
8589 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
8589 INFO: Loading module hook "hook-_tkinter.py"...
8712 INFO: checking Tree
8712 INFO: Building Tree because Tree-00.toc is non existent
8712 INFO: Building Tree Tree-00.toc
8719 INFO: checking Tree
8719 INFO: Building Tree because Tree-01.toc is non existent
8719 INFO: Building Tree Tree-01.toc
8722 INFO: Loading module hook "hook-xml.py"...
8898 INFO: Loading module hook "hook-encodings.py"...
8975 INFO: Looking for ctypes DLLs
9004 INFO: Analyzing run-time hooks ...
9008 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
9014 INFO: Including run-time hook 'pyi_rth__tkinter.py'
9034 INFO: Looking for dynamic libraries
9823 INFO: Looking for eggs
9823 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
File "/usr/bin/pyinstaller", line 11, in <module>
load_entry_point('PyInstaller==3.5+498e6ee058', 'console_scripts', 'pyinstaller')()
File "/usr/lib/python3/dist-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/lib/python3/dist-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/lib/python3/dist-packages/PyInstaller/building/build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/usr/lib/python3/dist-packages/PyInstaller/building/build_main.py", line 791, in build
exec(code, spec_namespace)
File "/home/kali/Py_Projects/turtles.spec", line 6, in <module>
a = Analysis(['turtles.py'],
File "/usr/lib/python3/dist-packages/PyInstaller/building/build_main.py", line 243, in __init__
self.__postinit__()
File "/usr/lib/python3/dist-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
self.assemble()
File "/usr/lib/python3/dist-packages/PyInstaller/building/build_main.py", line 575, in assemble
self._check_python_library(self.binaries)
File "/usr/lib/python3/dist-packages/PyInstaller/building/build_main.py", line 666, in _check_python_library
python_lib = bindepend.get_python_library_path()
File "/usr/lib/python3/dist-packages/PyInstaller/depend/bindepend.py", line 914, in get_python_library_path
python_libname = findLibrary(name)
File "/usr/lib/python3/dist-packages/PyInstaller/depend/bindepend.py", line 778, in findLibrary
utils.load_ldconfig_cache()
File "/usr/lib/python3/dist-packages/PyInstaller/depend/utils.py", line 375, in load_ldconfig_cache
path = m.groups()[-1]
AttributeError: 'NoneType' object has no attribute 'groups'
It seems a fairly straight forward process, I have updated both python and pyinstaller...not sure where to go next. Any help?

Bad Gateway 502 Error upgrading app from Python 3.7 to Python 3.8

After successfully porting from Python 2.7 to 3.7 on Google App Engine, I decided to try upgrading to Python 3.8 runtime.
The only changes I made in the configuration from Python 3.7 was to specify the python38 runtime in the app.yaml file and to add google-cloud-datastore to requirements.txt
When I deploy and run the app runtime,I get a Bad Gateway 502 (nginx). Below is the stderr log:
Traceback (most recent call last):
File "/layers/google.python.webserver/gunicorn/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/gthread.py", line 92, in init_process
super().init_process()
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/layers/google.python.webserver/gunicorn/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/layers/google.python.webserver/gunicorn/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/layers/google.python.webserver/gunicorn/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/layers/google.python.webserver/gunicorn/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/layers/google.python.webserver/gunicorn/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/opt/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/srv/main.py", line 2, in <module>
from google.cloud import ndb
File "/layers/google.python.pip/pip/google/cloud/ndb/__init__.py", line 28, in <module>
from google.cloud.ndb.client import Client
File "/layers/google.python.pip/pip/google/cloud/ndb/client.py", line 26, in <module>
from google.cloud.datastore_v1.gapic import datastore_client
ModuleNotFoundError: No module named 'google.cloud.datastore_v1.gapic'
My requirements.txt file has the following:
googleapis_common_protos
google-cloud-ndb
google-cloud-datastore
Flask==0.10.1
I do not specify an entry point in the app.yaml file. Per the docs, there is no requirement to include gunicorn in requirments.txt in that case. Initially I did not have the google-cloud-datastore library included. Python37 runtime did not need it. Seems to make no difference wrt the error with python38 runtime.
As mentioned this works perfectly with the python37 runtime.
Thanks.
Looks like it was the
Flask==0.10.1 in requirements.txt. Took out the version spec, and removed
google-cloud-datastore, as redundant.
All works now.
Sorry to have troubled you with this. But I guess posting the question, helped me see the problem with specifying an old version of flask.
Regards,
S

AttributeError: module 'django.db.models' has no attribute 'JSONField'

Following Django 3.1 guidelines for JSONField for all supported database backends…
https://docs.djangoproject.com/en/3.1/releases/3.1/#jsonfield-for-all-supported-database-backends
WARNINGS:
users.Search.input: (fields.W904) django.contrib.postgres.fields.JSONField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
HINT: Use django.db.models.JSONField instead.
from django.db import models
class ContactInfo(models.Model):
data = models.JSONField()
… ends up with error on Azure Web App:
AttributeError: module 'django.db.models' has no attribute 'JSONField'
Requirements.txt file specifies Django >= 3.1:
Django >= 3.1
App Service Built console:
##[group]Run azure/appservice-build#v1
with:
platform: python
platform-version: 3.8
env:
pythonLocation: /opt/hostedtoolcache/Python/3.8.5/x64
...
No source directory was provided -- the root of the repository ('GITHUB_WORKSPACE' environment variable) will be built: '/github/workspace'
No output directory was provided
Platform provided: 'python'
Platform version provided: '3.8'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 131 100 131 0 0 262 0 --:--:-- --:--:-- --:--:-- 262
100 131 100 131 0 0 262 0 --:--:-- --:--:-- --:--:-- 262
Running command 'oryx build /github/workspace --platform python --platform-version 3.8 --enable-dynamic-install'
Build orchestrated by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues
Oryx Version : 0.2.20200312.2, Commit: d1cf6b4a89345b6a7d0dc25d0fbd67860862ee18, ReleaseTagName: 20200312.2
Build Operation ID: |xt2zaWLFTwY=.5ad82150_
Repository Commit : 75be0048ee098cbf42a032200e6ef6867a48b924
Source directory : /github/workspace
Destination directory: /github/workspace
Python Version: /opt/python/3.8.2/bin/python3
Python Virtual Environment: pythonenv3.8
Creating virtual environment ...
Activating virtual environment ...
Upgrading pip...
WARNING: The directory '/github/home/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl (1.5MB)
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-20.2.3
Done in 2 sec(s).
Running pip install...
Collecting Django>=3.1
Downloading Django-3.1.1-py3-none-any.whl (7.8 MB)
Collecting psycopg2-binary
Downloading psycopg2_binary-2.8.6-cp38-cp38-manylinux1_x86_64.whl (3.0 MB)
...
Building wheels for collected packages: isort
Building wheel for isort (PEP 517): started
Building wheel for isort (PEP 517): finished with status 'done'
Created wheel for isort: filename=isort-5.5.2-py3-none-any.whl size=96676 sha256=51272461d0c723dd22ff1a2f9eeb14b85dcb526eb89afaeaa56a444601358acd
Stored in directory: /tmp/pip-ephem-wheel-cache-2s_h_h49/wheels/1e/39/35/2df4c05d92066f85f187318ea94000afe7a684a28361f823cb
Successfully built isort
...
Successfully installed Django-3.1.1 PyJWT-1.7.1 apscheduler-3.6.3 asgiref-3.2.10 astroid-2.4.2 azure-common-1.1.25 azure-core-1.8.1 azure-identity-1.0.1 azure-keyvault-secrets-4.0.0 cachetools-4.1.1 certifi-2020.6.20 cffi-1.14.2 chardet-3.0.4 click-7.1.2 cryptography-3.1 defusedxml-0.6.0 diff-match-patch-20200713 django-apscheduler-0.3.0 django-braces-1.14.0 django-cas-ng-4.1.1 django-crispy-forms-1.9.2 django-debug-toolbar-2.2 django-import-export-2.3.0 django-money-1.1 django-pandas-0.6.2 et-xmlfile-1.0.1 google-api-core-1.22.2 google-auth-1.21.1 googleapis-common-protos-1.52.0 googletrans-3.0.0 h11-0.9.0 h2-3.2.0 hpack-3.0.0 hstspreload-2020.9.9 httpcore-0.9.1 httpx-0.13.3 hyperframe-5.2.0 idna-2.10 isodate-0.6.0 isort-5.5.2 jdcal-1.4.1 joblib-0.16.0 lazy-object-proxy-1.4.3 lxml-4.5.2 markuppy-1.14 mccabe-0.6.1 msal-1.5.0 msal-extensions-0.1.3 msrest-0.6.19 nltk-3.5 numpy-1.19.2 oauthlib-3.1.0 odfpy-1.4.1 opencensus-0.7.10 opencensus-context-0.1.1 opencensus-ext-azure-1.0.4 opencensus-ext-django-0.7.2 opencensus-ext-logging-0.1.0 opencensus-ext-postgresql-0.1.2 openpyxl-3.0.5 pandas-1.1.2 portalocker-1.7.1 protobuf-3.13.0 psutil-5.7.2 psycopg2-binary-2.8.6 py-moneyed-0.8.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 pycparser-2.20 pylint-2.6.0 python-cas-1.5.0 python-dateutil-2.8.1 python-docx-0.8.10 pytz-2020.1 pyyaml-5.3.1 rake-nltk-1.0.4 regex-2020.7.14 requests-2.24.0 requests-oauthlib-1.3.0 rfc3986-1.4.0 rsa-4.6 scikit-learn-0.23.2 scipy-1.5.2 six-1.15.0 sniffio-1.1.0 sqlparse-0.3.1 tablib-2.0.0 threadpoolctl-2.1.0 toml-0.10.1 tqdm-4.49.0 tzlocal-2.1 urllib3-1.25.10 whitenoise-5.2.0 wrapt-1.12.1 xlrd-1.2.0 xlwt-1.3.0
Done running pip install.
Content in source directory is a Django app
Running collectstatic ...
248 static files copied to '/github/workspace/staticfiles', 614 post-processed.
'collectstatic' exited with exit code .
Done in 3 sec(s).
Removing existing manifest file
Creating a manifest file...
Manifest file created.
Done in 65 sec(s).
Oryx console:
INFO - Starting container for site
INFO - docker run -d -p 2747:8000 --name azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7 -e WEBSITE_SITE_NAME=azapp-rio-analyse-k6xbl -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=azapp-rio-analyse-k6xbl-dev.azurewebsites.net -e WEBSITE_INSTANCE_ID=945195e1f60010c33c817fd7ae1c28de08dc486224321f51d599531c29bb5725 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.8_20200707.6
INFO - Initiating warmup request to container azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7_msiProxy for site azapp-rio-analyse-k6xbl__6cdd
INFO - Container azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7_msiProxy for site azapp-rio-analyse-k6xbl__6cdd initialized successfully and is ready to serve requests.
INFO - Initiating warmup request to container azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7 for site azapp-rio-analyse-k6xbl__6cdd
_____
/ _ \ __________ _________ ____
/ /_\ \___ / | \_ __ \_/ __ \
/ | \/ /| | /| | \/\ ___/
\____|__ /_____ \____/ |__| \___ >
\/ \/ \/
A P P S E R V I C E O N L I N U X
Documentation: http://aka.ms/webapp-linux
Python 3.8.3
Note: Any data outside '/home' is not persisted
Starting OpenBSD Secure Shell server: sshd.
App Command Line not configured, will attempt auto-detect
Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
Build Operation ID: |mt6xPWP5VVs=.cc9e7dda_
Oryx Version: 0.2.20200706.2, Commit: 42be45d884938c3c818ba08e9e4760b1136fd9b3, ReleaseTagName: 20200706.2
Detected an app based on Django
Generating `gunicorn` command for 'main.wsgi'
Writing output script to '/opt/startup/startup.sh'
Using packages from virtual environment pythonenv3.8 located at /home/site/wwwroot/pythonenv3.8.
Updated PYTHONPATH to ':/home/site/wwwroot/pythonenv3.8/lib/python3.8/site-packages'
[2020-09-13 16:29:57 +0000] [37] [INFO] Starting gunicorn 20.0.4
[2020-09-13 16:29:57 +0000] [37] [INFO] Listening at: http://0.0.0.0:8000 (37)
[2020-09-13 16:29:57 +0000] [37] [INFO] Using worker: sync
[2020-09-13 16:29:57 +0000] [39] [INFO] Booting worker with pid: 39
INFO:opencensus.ext.postgresql.trace:Integrated module: postgresql
[2020-09-13 18:30:13 +0200] [39] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
self.load_wsgi()
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
self.wsgi = self.app.wsgi()
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
return self.load_wsgiapp()
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/python/3.8.3/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
mod = importlib.import_module(module)
File "/opt/python/3.8.3/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/site/wwwroot/main/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/site/wwwroot/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/home/site/wwwroot/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/site/wwwroot/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/site/wwwroot/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/opt/python/3.8.3/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/site/wwwroot/users/models.py", line 25, in <module>
class ContactInfo(models.Model):
File "/home/site/wwwroot/users/models.py", line 29, in Search
data = models.JSONField(encoder=DjangoJSONEncoder, null=True, db_index=True)
AttributeError: module 'django.db.models' has no attribute 'JSONField'
[2020-09-13 18:30:13 +0200] [39] [INFO] Worker exiting (pid: 39)
[2020-09-13 16:30:13 +0000] [37] [INFO] Shutting down: Master
[2020-09-13 16:30:13 +0000] [37] [INFO] Reason: Worker failed to boot.
ERROR - Container azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7 for site azapp-rio-analyse-k6xbl__6cdd has exited, failing site start
ERROR - Container azapp-rio-analyse-k6xbl__6cdd_0_ee823bd7 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
INFO - Stopping site azapp-rio-analyse-k6xbl__6cdd because it failed during startup.
I ran into this issue with my docker app when I forgot to update my requirements.txt file to use Django>=3.1.0,<3.2.0, instead of Django 3.0.8. I also had to run docker-compose build after updating that.
I saw this error because I was using pipenv in my project and had forgotten to run pipenv shell command before running the app.
I have the same problem while trying to run my application on my server.
Locally (ubuntu-20.04) it works with
Python==3.6.7
Django==3.1.3
but on my server (debian-stretch) with the same version of django and python, I got the same problem!
I've tryied with django==3.0 and the problem remains
Nov 05...gunicorn[19911]: created_group = models.JSONField(default=default_created_group)
Nov 05...gunicorn[19911]: AttributeError: module 'django.db.models' has no attribute 'JSONField'
The only way to apply the new models JSONField recommendation is to use Django 3.1
Actually our wwwroot folder contained errant files and folders dating back from previous git pushes never cleaned-up, among them an old install of Django v3.0.5 not erased.
Accessing wwwroot with FTP ftps://...ftp.azurewebsites.windows.net/site/wwwroot and erasing all its content solved this issue.

After importing and using numpy, can no longer convert .py to .exe

I wrote a simple script that takes user input and creates a .txt. My first iteration only wrote to the file and did not other work on the file. I added numpy library for the genfromtxt and find features. the code runs perfectly, but when I try to convert to an .exe file it will not package. The only additions to the script is numpy, and the previous version without it packaged without issue.
I'm a pretty novice coder and this may not be a numpy issue, but this is my best reasonable guess.
I have written other .py scripts and converted them to .exe that do not use numpy, and I don't have any issues. But those are not importing third party libraries... This is why I believe it has something to do with numpy and the dependancies...
COMMAND LINE:
pyinstaller -y "C:/Users/adamt/Desktop/QA Lot Tracking Application/QAInternalTrackingApp_v5.py"
Reproducing code example:
****NOT APPLICABLE: Error is in conversion from .py to .exe. The code runs fine in the editor (PyCharm).
OUTPUT from running command line:
Running auto-py-to-exe v2.6.5
Building in the current instances temporary directory at C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8
To get a new temporary directory, restart this application
Recursion Limit is set to 5000
Executing: pyinstaller -y "C:/Users/adamt/Desktop/QA Lot Tracking Application/QAInternalTrackingApp_v5.py"
60089327 INFO: PyInstaller: 3.5
60089330 INFO: Python: 3.7.0
60089330 INFO: Platform: Windows-10-10.0.18362-SP0
60089335 INFO: wrote C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8\QAInternalTrackingApp_v5.spec
60089348 INFO: UPX is not available.
60089373 INFO: Extending PYTHONPATH with paths
['C:\\Users\\adamt\\Desktop\\QA Lot Tracking Application',
'C:\\Users\\adamt\\AppData\\Local\\Temp\\tmp6a58x7u8']
60089375 INFO: checking Analysis
60089375 INFO: Building Analysis because Analysis-01.toc is non existent
60089376 INFO: Initializing module dependency graph...
60089399 INFO: Initializing module graph hooks...
60089417 INFO: Analyzing base_library.zip ...
60093336 INFO: running Analysis Analysis-01.toc
60093340 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\program files\python37\python.exe
60094382 INFO: Caching module hooks...
60094400 INFO: Analyzing C:\Users\adamt\Desktop\QA Lot Tracking Application\QAInternalTrackingApp_v5.py
60094981 INFO: Processing pre-find module path hook distutils
60096595 INFO: Processing pre-find module path hook site
60096596 INFO: site: retargeting to fake-dir 'C:\\Users\\adamt\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\fake-modules'
60099890 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
60103279 INFO: Loading module hooks...
60103279 INFO: Loading module hook "hook-distutils.py"...
60103282 INFO: Loading module hook "hook-encodings.py"...
60103422 INFO: Loading module hook "hook-gevent.py"...
**60103726 WARNING: Unable to find package for requirement greenlet from package gevent.
60103727 INFO: Packages required by gevent:
['cffi']**
60104984 INFO: Loading module hook "hook-jinja2.py"...
60105008 INFO: Loading module hook "hook-lib2to3.py"...
60105017 INFO: Loading module hook "hook-numpy.core.py"...
An error occurred, traceback follows:
Traceback (most recent call last):
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\auto_py_to_exe\__main__.py", line 269, in convert
pyi.run() # Execute PyInstaller
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8\QAInternalTrackingApp_v5.spec", line 17, in <module>
noarchive=False)
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
self.__postinit__()
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 502, in assemble
module_hook.post_graph()
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\compat.py", line 793, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 27, in <module>
pkg_base, pkg_dir = get_package_paths('numpy.core')
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py", line 535, in get_package_paths
file_attr = get_module_file_attribute(package)
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py", line 318, in get_module_file_attribute
loader = pkgutil.find_loader(package)
File "c:\program files\python37\lib\pkgutil.py", line 493, in find_loader
spec = importlib.util.find_spec(fullname)
File "c:\program files\python37\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "c:\program files\python37\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
Project output will not be moved to output folder
Complete.

Pyinstaller fails with pyscard on windows

I am trying to use pyinstaller on a simple script which use pyscard.
from smartcard.Exceptions import NoCardException
from smartcard.System import readers
from smartcard.util import toHexString
for reader in readers():
try:
connection = reader.createConnection()
connection.connect()
print(reader, toHexString(connection.getATR()))
except NoCardException:
print(reader, 'no card inserted')
This is OK on Ubuntu but fails on Windows7 and Windows10 machines.
The failure is the same on both versions of windows, here is the screen output on Windows7:
C:\Users\seb\ownCloud\rex>pyinstaller --clean --win-private-assemblies --hidden-import=smartcard.scard._scard --onefile testpyscard.py
55 INFO: PyInstaller: 3.3.1
55 INFO: Python: 3.6.5
56 INFO: Platform: Windows-7-6.1.7601-SP1
57 INFO: wrote C:\Users\seb\ownCloud\rex\testpyscard.spec
60 INFO: UPX is not available.
60 INFO: Removing temporary files and cleaning cache in C:\Users\seb\AppData\Roaming\pyinstaller
74 INFO: Extending PYTHONPATH with paths
['C:\\Users\\seb\\ownCloud\\rex', 'C:\\Users\\seb\\ownCloud\\rex']
75 INFO: checking Analysis
76 INFO: Building Analysis because out00-Analysis.toc is non existent
76 INFO: Initializing module dependency graph...
79 INFO: Initializing module graph hooks...
81 INFO: Analyzing base_library.zip ...
2472 INFO: Analyzing hidden import 'smartcard.scard._scard'
2564 INFO: running Analysis out00-Analysis.toc
2566 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Python36\python.exe
3106 INFO: Caching module hooks...
3111 INFO: Analyzing C:\Users\seb\ownCloud\rex\testpyscard.py
3115 INFO: Loading module hooks...
3115 INFO: Loading module hook "hook-encodings.py"...
3195 INFO: Loading module hook "hook-pydoc.py"...
3196 INFO: Loading module hook "hook-xml.py"...
3382 INFO: Looking for ctypes DLLs
3383 INFO: Analyzing run-time hooks ...
3388 INFO: Looking for dynamic libraries
3461 INFO: Looking for eggs
3461 INFO: Using Python library C:\Python36\python36.dll
3462 INFO: Found binding redirects:
[]
3465 INFO: Warnings written to C:\Users\seb\ownCloud\rex\build\testpyscard\warntestpyscard.txt
3501 INFO: Graph cross-reference written to C:\Users\seb\ownCloud\rex\build\testpyscard\xref-testpyscard.html
3506 INFO: checking PYZ
3507 INFO: Building PYZ because out00-PYZ.toc is non existent
3507 INFO: Building PYZ (ZlibArchive) C:\Users\seb\ownCloud\rex\build\testpyscard\out00-PYZ.pyz
3910 INFO: Building PYZ (ZlibArchive) C:\Users\seb\ownCloud\rex\build\testpyscard\out00-PYZ.pyz completed successfully.
3914 INFO: checking PKG
3914 INFO: Building PKG because out00-PKG.toc is non existent
3915 INFO: Building PKG (CArchive) out00-PKG.pkg
3929 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\python36.dll
3930 INFO: Updating resource type 24 name 2 language 1033
4036 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_ssl.pyd
4036 INFO: Updating resource type 24 name 2 language 1033
4047 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\unicodedata.pyd
4048 INFO: Updating resource type 24 name 2 language 1033
4055 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\pyexpat.pyd
4056 INFO: Updating resource type 24 name 2 language 1033
4066 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_hashlib.pyd
4066 INFO: Updating resource type 24 name 2 language 1033
4075 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\select.pyd
4076 INFO: Updating resource type 24 name 2 language 1033
4083 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_bz2.pyd
4083 INFO: Updating resource type 24 name 2 language 1033
4089 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_lzma.pyd
4089 INFO: Updating resource type 24 name 2 language 1033
4095 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_socket.pyd
4095 INFO: Updating resource type 24 name 2 language 1033
4100 INFO: Updating manifest in C:\Users\seb\AppData\Roaming\pyinstaller\bincache00_py36_64bit\_scard.pyd
4100 INFO: Updating resource type 24 name 2 language 1033
5488 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
5490 INFO: Bootloader C:\Python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
5491 INFO: checking EXE
5491 INFO: Building EXE because out00-EXE.toc is non existent
5492 INFO: Building EXE from out00-EXE.toc
5493 INFO: Appending archive to EXE C:\Users\seb\ownCloud\rex\dist\testpyscard.exe
5499 INFO: Building EXE from out00-EXE.toc completed successfully.
C:\Users\seb\ownCloud\rex>.\dist\testpyscard.exe
Traceback (most recent call last):
File "testpyscard.py", line 28, in <module>
from smartcard.Exceptions import NoCardException
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\__init__.py", line 29, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\System.py", line 28, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\reader\ReaderFactory.py", line 34, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\pcsc\PCSCReader.py", line 28, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\pcsc\PCSCContext.py", line 27, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\scard\__init__.py", line 1, in <module>
File "C:\Python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\smartcard\scard\scard.py", line 119, in <module>
File "site-packages\smartcard\scard\scard.py", line 118, in swig_import_helper
File "importlib\__init__.py", line 126, in import_module
ModuleNotFoundError: No module named 'smartcard.scard._scard'
[7924] Failed to execute script testpyscard
Note: The optional arguments to pyinstaller do not make any difference, I tried the 8 combinations with and without --onefile, --hidden-import and --win-private-assemblies. On ubuntu pyinstaller was invoked simply with the name of the script and --onefile.
Note 2: I had the same issue with Python3.6-32 on the Windows7 machine. I uninstalled all the python stuff I could find on the machine and made a fresh install of Python3.6 x86-64 and the matching pyscard (using dist\pyscard-1.9.6.win-amd64-py3.6.msi from https://ci.appveyor.com/project/LudovicRousseau/pyscard)
Any help to understand or fix the issue would be greatly appreciated, I don't even know if the problem is related to my setup or Pyinstaller or Pyscard :-S
I had same issue on Windows 7 and Windows 10. I think the problems occurs because of the runtime import in the swig_import_helper function in scard.py. So I have added following to my PyInstaller options:
--add-data "path_to_python\\Python36-32\\Lib\\site-packages\\smartcard\\scard\\_scard.cp36-win32.pyd;.\\smartcard\\scard\\"
This fixed the problem for me both under Windows 7 and Windows 10.
My testing environment:
Windows 7 64 bit
Python 3.6 32 bit
pyscard 1.9.7
PyInstaller 3.3.1

Resources