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.
Related
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
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.
I have deployed Python-Flask API in Azure. Its working fine in development environment. It has following dependencies which is mentioned in a .txt file.
click==6.7
Flask==1.0.2
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
Werkzeug==0.14.1
jsonpickle==1.0
pyodbc==4.0.25
I have an app.py class which has some function that contains some DB CURD operations. It also has a db.py which contain below code :
import pyodbc
cnxn = pyodbc.connect(cs)
But when I am navigating to https://kmsazapi.azurewebsites.net/ it is giving below error
:( Application Error. If you are the application administrator, you can access the diagnostic resources.
Please find the Application logs from Azure :
2019-01-19T16:30:46.743756546Z
2019-01-19T16:30:46.893500456Z Starting OpenBSD Secure Shell server: sshd.
2019-01-19T16:30:46.921319668Z Running python /usr/local/bin/entrypoint.py
2019-01-19T16:30:47.042444539Z executing:
2019-01-19T16:30:47.042628845Z python --version
2019-01-19T16:30:47.060630336Z Python 3.7.1
2019-01-19T16:30:47.060830442Z executing:
2019-01-19T16:30:47.060993448Z pip --version
2019-01-19T16:30:49.209547693Z pip 10.0.1 from /home/site/wwwroot/antenv/lib/python3.7/site-packages/pip (python 3.7)
2019-01-19T16:30:49.214266747Z found flask app
2019-01-19T16:30:49.219978635Z executing:
2019-01-19T16:30:49.219990835Z . antenv/bin/activate
2019-01-19T16:30:49.224706090Z
2019-01-19T16:30:49.224798193Z executing:
2019-01-19T16:30:49.224971698Z GUNICORN_CMD_ARGS="--bind=0.0.0.0 --timeout 600" gunicorn application:app
2019-01-19T16:30:50.183264018Z [2019-01-19 16:30:50 +0000] [36] [INFO] Starting gunicorn 19.9.0
2019-01-19T16:30:50.183984042Z [2019-01-19 16:30:50 +0000] [36] [INFO] Listening at: http://0.0.0.0:8000 (36)
2019-01-19T16:30:50.184216749Z [2019-01-19 16:30:50 +0000] [36] [INFO] Using worker: sync
2019-01-19T16:30:50.194083973Z [2019-01-19 16:30:50 +0000] [39] [INFO] Booting worker with pid: 39
2019-01-19T16:30:50.967282324Z [2019-01-19 16:30:50 +0000] [39] [ERROR] Exception in worker process
2019-01-19T16:30:50.967302024Z Traceback (most recent call last):
2019-01-19T16:30:50.967306124Z File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-01-19T16:30:50.967311525Z worker.init_process()
2019-01-19T16:30:50.967325625Z File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-01-19T16:30:50.967329625Z self.load_wsgi()
2019-01-19T16:30:50.967332825Z File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-01-19T16:30:50.967336425Z self.wsgi = self.app.wsgi()
2019-01-19T16:30:50.967347026Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-01-19T16:30:50.967350926Z self.callable = self.load()
2019-01-19T16:30:50.967354226Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-01-19T16:30:50.967357626Z return self.load_wsgiapp()
2019-01-19T16:30:50.967361026Z File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-01-19T16:30:50.967364426Z return util.import_app(self.app_uri)
2019-01-19T16:30:50.967367726Z File "/usr/local/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-01-19T16:30:50.967371427Z import(module)
2019-01-19T16:30:50.967374727Z File "/home/site/wwwroot/application.py", line 7, in
2019-01-19T16:30:50.967378427Z import db
2019-01-19T16:30:50.967381627Z File "/home/site/wwwroot/db.py", line 1, in
2019-01-19T16:30:50.967385027Z import pyodbc
2019-01-19T16:30:50.967388327Z ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
2019-01-19T16:30:50.967653236Z [2019-01-19 16:30:50 +0000] [39] [INFO] Worker exiting (pid: 39)
2019-01-19T16:30:51.050986468Z [2019-01-19 16:30:51 +0000] [36] [INFO] Shutting down: Master
2019-01-19T16:30:51.051229076Z [2019-01-19 16:30:51 +0000] [36] [INFO] Reason: Worker failed to boot.
2019-01-19T16:30:51.102156846Z
What I am missing ?
Update: 0115:
If you deploy the python app to web app for windows, you can install the python extension as below: Go to azure portal -> your app service -> Extensions -> Add -> choose extensions:
How do you deploy your flask app?
You can refer to the official doc for the deployment. I followed the doc, and can work well in azure with the site https://xxx.azurewebsites.net/home .
my code:
from flask import Flask
app = Flask(__name__)
#app.route("/home")
def home():
return "Hello World a nice day!"
after deploy to azure, the site works well:
I am trying to configure airflow webserver and scheduler to run. It is a python application.
I used "python setup.py install" and then using the shell comand:
(start-stop-daemon --start --quiet --exec airflow webserver) started the processes.
Everything works ok.
But when I create a daemon script, on init.d i am getting:
2015-12-09 13:41:29,808 - root - INFO - Filling up the DagBag from /home/pedro/airflow/dags
2015-12-09 13:41:29,810 - root - INFO - Importing /home/pedro/airflow/dags/simple_ecs_dag.py
2015-12-09 13:41:29,830 - root - INFO - Loaded DAG
Running the Gunicorn server with 4 syncworkers on host 0.0.0.0 and port 8080...
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 4, in
import('pkg_resources').run_script('airflow==1.6.1', 'airflow')
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 742, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 1667, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/airflow-1.6.1-py2.7.egg/EGG-INFO/scripts/airflow", line 17, in
args.func(args)
File "/usr/local/lib/python2.7/dist-packages/airflow-1.6.1-py2.7.egg/airflow/bin/cli.py", line 338, in webserver
'airflow.www.app:cached_app()'])
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I imagine that the start-stop-daemon running or the python process are running under diferent users.
Does anyone can help me?
im running a fabric script that, amongst other things, is supposed to restart gunicorn on an ubuntu server, the command is below:
supervisorctl status projectname:gunicorn | sed "s/.*[pid ]\([0-9]\+\)\,.*/\1/" | xargs kill -HUP
the problem is, is that gunicorn doesnt appear to be running in the first place so the process cannot be killed, ive ssh'd into the amazon ec2 instance and ran
sudo supervisorctl restart projectname:gunicorn'
and I get an error response that says:
projectname:gunicorn: ERROR (not running)
projectname:gunicorn ERROR (abnormal termination)
so i attempted to start gunicorn by running
sudo supervisorctl start projectname:gunicorn
and the error says
'projectname:gunicorn: Error (abnormal termination)'
So I need gunicorn to run, and im having trouble acheiving this
Ive also checked the gunicorn log and the text below, below is the relevant output
2014-01-17 14:58:14 [12260] [INFO] Starting gunicorn 0.14.3
2014-01-17 14:58:14 [12260] [INFO] Listening at: http://127.0.0.1:9000 (12260)
2014-01-17 14:58:14 [12260] [INFO] Using worker: sync
2014-01-17 14:58:14 [12263] [INFO] Booting worker with pid: 12263
2014-01-17 14:58:14 [12264] [INFO] Booting worker with pid: 12264
2014-01-17 14:58:14 [12265] [INFO] Booting worker with pid: 12265
2014-01-17 14:58:14 [12266] [INFO] Booting worker with pid: 12266
2014-01-17 14:58:14 [12263] [INFO] Worker exiting (pid: 12263)
2014-01-17 14:58:14 [12264] [INFO] Worker exiting (pid: 12264)
2014-01-17 14:58:14 [12265] [INFO] Worker exiting (pid: 12265)
2014-01-17 14:58:14 [12266] [INFO] Worker exiting (pid: 12266)
Traceback (most recent call last):
File "/opt/screening/env/bin/gunicorn_django", line 9, in <module>
load_entry_point('gunicorn==0.14.3', 'console_scripts', 'gunicorn_django')()
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 129, in run
DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run()
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 129, in run
Arbiter(self).run()
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 184, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 279, in halt
self.stop()
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 327, in stop
self.reap_workers()
File "/opt/compliance_engine/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 413, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
also, here is the conf file
[program:gunicorn]
command=/opt/screening/env/bin/gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000
directory=/opt/screening/repository
user=www-data
autostart=true
autorestart=true
stdout_logfile=/opt/screening/logs/gunicorn.log
redirect_stderr=true
[program:celeryd]
command=/opt/screening/env/bin/python manage.py celeryd --autoscale=16,2 -E -l INFO --pidfile=/opt/screening/tmp/pids/celeryd.pid
directory=/opt/screening/repository
user=www-data
autostart=true
autorestart=true
stdout_logfile=/opt/screening/logs/celeryd.log
redirect_stderr=true
[program:celerybeat]
command=/opt/screening/env/bin/python manage.py celerybeat -l INFO -- schedule=/opt/screening/tmp/celerybeat-schedule -- pidfile=/opt/screening/tmp/pids/celerybeat.pid
directory=/opt/screening/repository
user=www-data
autostart=true
autorestart=true
stdout_logfile=/opt/screening/logs/celerybeat.log
redirect_stderr=true
[program:celerycam]
command=/opt/screening/env/bin/python manage.py celerycam -- pidfile=/opt/screening/tmp/pids/celerycam.pid
directory=/opt/screening/repository
user=www-data
autostart=true
autorestart=true
stdout_logfile=/opt/screening/logs/celerycam.log
redirect_stderr=true
[group:screening]
programs=gunicorn,celeryd,celerybeat,celerycam
any ideas? I understand that this is a lot of text, any hints or pointers would be much appreciated
Thanks for reading,
edit:
ran unicorn on its own, activated the virtual env and ran
python manage.py run_gunicorn
the terminal printed the below output
2014-01-19 22:02:35 [14735] [INFO] Starting gunicorn 0.14.3
2014-01-19 22:02:35 [14735] [INFO] Listening at: http://127.0.0.1:8000 (14735)
2014-01-19 22:02:35 [14735] [INFO] Using worker: sync
2014-01-19 22:02:35 [14742] [INFO] Booting worker with pid: 14742
also ran the run server in the virtualenv:
python manage.py runserver 7000
Validating models...
0 errors found
Django version 1.3, using settings 'ce.settings'
Development server is running at http://127.0.0.1:7000/
Quit the server with CONTROL-C.
so no apparent errors there
edit 2:
have spoken to a couple other people about this, and was advised to look at the permissions for the gunicorn logs, here they are:
-rw-rw-r-- 1 www-data ubuntu 3270504 2014-01-19 23:23 gunicorn.log
the www-data user matches the one set in the supervisor config
edit 3: I ran the gunicorn command again, but this time added logging info:
gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000 --debug --log-level debug
and received the following error message:
Traceback (most recent call last):
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 453, in spawn_worker
worker.init_process()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 99, in init_process
self.wsgi = self.app.wsgi()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 101, in wsgi
self.callable = self.load()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 87, in load
mod = util.import_module("gunicorn.app.django_wsgi")
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 18, in <module>
from django.core.management.validation import get_validation_errors
File "/opt/screening/env/local/lib/python2.7/site-packages/django/core/management/validation.py", line 3, in <module>
from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
File "/opt/screening/env/local/lib/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 6, in <module>
from django.db import connection
File "/opt/screening/env/local/lib/python2.7/site-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/opt/screening/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/opt/screening/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/opt/screening/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 89, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'ce.settings' (Is it on sys.path?): No module named ce.settings
2014-01-20 09:14:22 [31830] [INFO] Worker exiting (pid: 31830)
Traceback (most recent call last):
File "/opt/screening/env/bin/gunicorn_django", line 9, in <module>
load_entry_point('gunicorn==0.14.3', 'console_scripts', 'gunicorn_django')()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 129, in run
DjangoApplication("%prog [OPTIONS] [SETTINGS_PATH]").run()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 129, in run
Arbiter(self).run()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 184, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 279, in halt
self.stop()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 327, in stop
self.reap_workers()
File "/opt/screening/env/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 413, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
so it appears that the salient info is this:
ImportError: Could not import settings 'ce.settings' (Is it on sys.path?): No module named ce.settings
My settings are in a settings directory, and the init file is present, so the issue isnt that.
Also the application starts on the runserver so the settings file must be importable
(The question was answered by the OP in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
Solved the issue (I think)
as per the info in this link https://stackoverflow.com/a/19256794/2049067 , I added the project to the python path
export PYTHONPATH=:/my/path
then ran the gunicorn command again:
gunicorn_django --pythonpath . ce.settings -w 4 --bind 127.0.0.1:9000 --debug --log-level debug
and gunicorn is up and running, and the site is accessible, I exited the ssh and everything is (seemingly) still working. I should also add that before I set the pythonpath I changed the ownerwhip on the gunicorn log:
sudo chown -R www-data:www-data gunicorn.log
Though I dont know if that helped
& seeing how the application has been running for years I dont know how the project was removed from the pythonpath