I'm deploying Django in Google App Engine.
I get 502 Bad Gateway and in the log I get the following error:
2021-03-08 12:08:18 default[20210308t130512] Traceback (most recent call last): File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/gthread.py", line 92, in init_process super().init_process() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/base.py", line 119, in init_process self.load_wsgi() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi self.wsgi = self.app.wsgi() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 49, in load return self.load_wsgiapp() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp return util.import_app(self.app_uri) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/gunicorn/util.py", line 358, in import_app mod = importlib.import_module(module) File "/opt/python3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in _call_with_frames_removed File "/srv/main.py", line 1, in from django_project.wsgi import application File "/srv/django_project/wsgi.py", line 16, in application = get_wsgi_application() File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/init.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 82, in getattr self._setup(name) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/layers/google.python.pip/pip/lib/python3.9/site-packages/django/conf/init.py", line 170, in init mod = importlib.import_module(self.SETTINGS_MODULE) File "/opt/python3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/srv/django_project/settings.py", line 84, in import pymysql # noqa: 402 ModuleNotFoundError: No module named 'pymysql'
The problem is that I already installed pymysql, in fact if I run pip3 install pymysql, I get Requirement already satisfied: ...
Why is that?
Thanks in advance!
Edit:
Here's requirements.txt:
asgiref==3.3.1
attrs==20.3.0
Automat==20.2.0
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
constantly==15.1.0
cryptography==3.4.1
cssselect==1.1.0
Django==3.1.6
django-phonenumber-field==5.0.0
django-widget-tweaks==1.4.8
hyperlink==21.0.0
idna==2.10
incremental==17.5.0
instaloader==4.6.1
itemadapter==0.2.0
itemloaders==1.0.4
jmespath==0.10.0
jsonfield==3.1.0
lxml==4.6.2
parsel==1.6.0
phonenumberslite==8.12.18
progress==1.5
Protego==0.1.16
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyDispatcher==2.0.5
PyHamcrest==2.0.2
pyOpenSSL==20.0.1
pytz==2021.1
queuelib==1.5.0
requests==2.25.1
schedule==0.6.0
Scrapy==2.4.1
semantic-version==2.8.5
service-identity==18.1.0
setuptools-rust==0.11.6
six==1.15.0
sqlparse==0.4.1
toml==0.10.2
urllib3==1.26.3
w3lib==1.22.0
zope.interface==5.2.0
If you run pip3 install pymysql in your local computer, this does not mean that when you deploy the app this module is packaged. In fact GAE attempts to install everything at build time using your requirements.txt file so it doesn't matter if you installed everything in your PC since GAE will not use what you have in local (talking about packages installed with pip).
Checking your requirements.txt file I do not see that the package PyMySQL is added. You should add it to that file and attempt to deploy again.
"pymysql" package is missing (not installed) according to the message below from your error:
ModuleNotFoundError: No module named 'pymysql'
So, you need to run this command below to install "pymysql":
pip install pymysql
Related
I have a Flask app running on Azure with a connection to an Azure SQL db and after the below developments I can't access the database any longer.
Here is what I recently added :
created a .env file to secure the connection string
added a .gitignore
added the following to my main.py:
connection_string = textwrap.dedent(f'''
Driver={driver};
Server={os.getenv("SERVER")};
Database={os.getenv("DB_NAME")};
Uid={os.getenv("DB_USER")};
Pwd={os.getenv("PASSWORD")};
Encrypt=yes;
TrustServerCertificate=no;
Connection Timeout=30;
''')
I've also added the following to run in production :
if __name__ == '__main__':
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
It works perfectly locally but as soon as I deploy it on Azure, I have issues with the docker deployment in the background. It seems the connection strings params are not recognized from the following error (from Kudu) :
Warning
2021-10-15T12:42:51.4960727
[2021-10-15 12:42:51 +0000] [40] [ERROR] Exception in worker process
Ok
2021-10-15T12:42:51.4961108
Traceback (most recent call last):
Ok
2021-10-15T12:42:51.4961177
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Ok
2021-10-15T12:42:51.4961354
worker.init_process()
Ok
2021-10-15T12:42:51.4961403
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Ok
2021-10-15T12:42:51.4961451
self.load_wsgi()
Ok
2021-10-15T12:42:51.4961495
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Ok
2021-10-15T12:42:51.4961542
self.wsgi = self.app.wsgi()
Ok
2021-10-15T12:42:51.4961586
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Ok
2021-10-15T12:42:51.4961638
self.callable = self.load()
Ok
2021-10-15T12:42:51.4961682
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Ok
2021-10-15T12:42:51.4961729
return self.load_wsgiapp()
Ok
2021-10-15T12:42:51.4961772
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Ok
2021-10-15T12:42:51.496182
return util.import_app(self.app_uri)
Ok
2021-10-15T12:42:51.4961864
File "/tmp/8d98fd8a8763182/antenv/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
Ok
2021-10-15T12:42:51.496191
mod = importlib.import_module(module)
Ok
2021-10-15T12:42:51.4961956
File "/opt/python/3.8.6/lib/python3.8/importlib/__init__.py", line 127, in import_module
Ok
2021-10-15T12:42:51.4962002
return _bootstrap._gcd_import(name[level:], package, level)
Ok
2021-10-15T12:42:51.496308
File "", line 1014, in _gcd_import
Ok
2021-10-15T12:42:51.496315
File "", line 991, in _find_and_load
Ok
2021-10-15T12:42:51.4963197
File "", line 975, in _find_and_load_unlocked
Ok
2021-10-15T12:42:51.4963244
File "", line 671, in _load_unlocked
Ok
2021-10-15T12:42:51.496329
File "", line 783, in exec_module
Ok
2021-10-15T12:42:51.4963337
File "", line 219, in _call_with_frames_removed
Ok
2021-10-15T12:42:51.4963383
File "/tmp/8d98fd8a8763182/main.py", line 104, in
Ok
2021-10-15T12:42:51.4965707
con, cur = AZconnect()
Ok
2021-10-15T12:42:51.496577
File "/tmp/8d98fd8a8763182/main.py", line 91, in AZconnect
Ok
2021-10-15T12:42:51.4965817
con: pyodbc.Connection = pyodbc.connect(connection_string)
Warning
2021-10-15T12:42:51.4965863
pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
I'm quite sure I did something wrong with the .env and load_dotenv() but I don't see where.
I understood my mistake ; .gitignore prenvented to use the .env file as it should hence the environment variable couldn't be set.
I then set these variable in Azure application settings and it worked just fine :
After running PREFIX=/home/hue make install
Towards the end of my hue install via tarball, I get the following error. I'm not sure what is happening. I have the prerequisites installed as well. Using this guide
Command that is failing: /home/hue/hue/build/env/bin/hue makemigrations --noinput
Error:
Traceback (most recent call last):
File "/home/hue/hue/build/env/bin/hue", line 11, in <module>
load_entry_point('desktop', 'console_scripts', 'hue')()
File "/home/hue/hue/desktop/core/src/desktop/manage_entry.py", line 216, in entry
execute_from_command_line(sys.argv)
File "/home/hue/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/hue/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/management/__init__.py", line 307, in execute
settings.INSTALLED_APPS
File "/home/hue/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/home/hue/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/hue/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/hue/hue/desktop/core/src/desktop/settings.py", line 271, in <module>
conf.initialize(_desktop_conf_modules, _config_dir)
File "/home/hue/hue/desktop/core/src/desktop/lib/conf.py", line 598, in initialize
conf_data = load_confs(_configs_from_dir(config_dir))
File "/home/hue/hue/desktop/core/src/desktop/lib/conf.py", line 530, in load_confs
for in_conf in conf_source:
File "/home/hue/hue/desktop/core/src/desktop/lib/conf.py", line 511, in _configs_from_dir
conf = ConfigObj(os.path.join(conf_dir, filename))
File "/home/hue/hue/build/env/lib/python2.7/site-packages/configobj-5.0.6-py2.7.egg/configobj.py", line 1229, in __init__
self._load(infile, configspec)
File "/home/hue/hue/build/env/lib/python2.7/site-packages/configobj-5.0.6-py2.7.egg/configobj.py", line 1318, in _load
raise error
configobj.ConfigObjError: Parsing failed with several errors.
First error at line 1046.
In case anyone else runs into this. So the issue stemmed from modifying the hue.ini file before running the install. Rolling back to the original hue.ini resolved the issue. I must have had a typo in the modified version, thus causing the parse error above.
Tarball File location:
hue/desktop/conf/hue.ini
On Fedora 27 when I run cookiecutter https://github.com/pydanny/cookiecutter-django I get:
File "/usr/bin/cookiecutter", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3038, in <module>
#_call_aside
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3022, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3051, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 657, in _build_master
ws.require(__requires__)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 971, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 857, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'future>=0.15.2' distribution was not found and is required by cookiecutter
This is a known issue:
python-cookiecutter-1.6.0-3.fc27 has been pushed to the Fedora 27 testing repository.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
I've followed this guide: https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Identity_Management_-KeyRock-_Installation_and_Administration_Guide
When i run the server i get:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named oslo.utils
I've tried using --pythonpath but to no avail. I've also ran ./run_tests.sh and here are the results: http://pastebin.com/6i7Ws5Ej.
System:
CentOS 6.5 x64,
python 2.6.6
Any idea how to solve this? any info i might have forgotten don’t hesitate to ask
Edit:
I've switched to ubuntu 12 to follow the tutorial step by step. I got keystone running but horizon still fails and gives me the same error.
A fix was also committed on KeyRock's Github account.
Here is the issue.
Manually updating pbr to 1.3.0 directly from python and pip solved all issues
Please tell me how solve this
I try install Install and configure a Sentry Service on a CentOS, and when i try start sentry service i get this error:
[root#felipeurrego ~]# source /var/www/sentry/bin/activate
(sentry)[root#felipeurrego ~]# sentry --config=/etc/sentry.conf.py start
Traceback (most recent call last):
File "/var/www/sentry/bin/sentry", line 8, in <module>
load_entry_point('sentry==5.4.5', 'console_scripts', 'sentry')()
File "/var/www/sentry/lib/python2.6/site-packages/sentry-5.4.5-py2.6.egg/sentry/utils/runner.py", line 197, in main
initializer=initialize_app,
File "/var/www/sentry/lib/python2.6/site-packages/logan-0.5.5-py2.6.egg/logan/runner.py", line 155, in run_app
management.execute_from_command_line([runner_name, command] + command_args)
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/utils/functional.py", line 184, in inner
self._setup()
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/conf/__init__.py", line 93, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/var/www/sentry/lib/python2.6/site-packages/Django-1.4.5-py2.6.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/var/www/sentry/lib/python2.6/site-packages/logan-0.5.5-py2.6.egg/logan/importer.py", line 68, in load_module
return self._load_module(fullname)
File "/var/www/sentry/lib/python2.6/site-packages/logan-0.5.5-py2.6.egg/logan/importer.py", line 92, in _load_module
load_settings(self.config_path, allow_extras=self.allow_extras, settings=settings_mod)
File "/var/www/sentry/lib/python2.6/site-packages/logan-0.5.5-py2.6.egg/logan/settings.py", line 49, in load_settings
execfile(mod_or_filename, conf.__dict__)
django.core.exceptions.ImproperlyConfigured: IndentationError('unexpected indent', ('/etc/sentry.conf.py', 58, 1, " SENTRY_URL_PREFIX = 'http://logs.felipeurrego.com'\n"))
And thats all
It's very clear:
django.core.exceptions.ImproperlyConfigured: IndentationError('unexpected indent', ('/etc/sentry.conf.py', 58, 1, " SENTRY_URL_PREFIX = 'http://logs.felipeurrego.com'\n"))
You have a unwarranted space before the configuration variable SENTRY_URL_PREFIX in your /etc/sentry.conf.py. Python requires that everything is uniformly indented in your source code files.