This is my very first time creating an .exe (or any package at all). Although I successfully created an exe-file of the kivy-touchtracer demo, according to the kivy-manual. I used the same approach to create an .exe from my kivy-app. It suppose to be running only on windows (first milestone).The non-exe version runs as I wanted. I could manage to create an .exe file, but somehow it is not running.Basically the programm should collect some data, "calculate a bit around" the given data, create some plots (matplotlib) and create a report-pdf (reportlab).
I already tried:
copy dateutils from python/Lib/sitepackages/dateutil into the created dist directory. (It helped by reportlab)
modifying the 'from .tz import *' line in dateutil/tz/init to 'from tz import *' (removing the dot)
They appeared useless...
How could I run my exe? What did I miss? (Matplotlib is in the supported-package list of pyinstaller.)
OS: Win7
Python: 3.4
My cal.spec file:
# -*- mode: python -*-
from kivy.deps import sdl2, glew
block_cipher = None
a = Analysis(['C:\\EZS-2G\\main.py'],
pathex=['C:\\EZS-2G\\calApp'],
binaries=None,
datas=None,
hiddenimports=['cycler','pyparsing','setuptools','tkinter','PyPDF2','jinja2','sqlite3','markupsafe','PIL','tornado','pytz','dateutil','reportlab','numpy','matplotlib'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Cal',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe, Tree('C:\\EZS-2G\\'),
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
name='Cal')
And here is my .kivy/log.txt as a result:
[INFO ] Logger: Record log in C:\Users\kalibrierlabor\.kivy\logs\kivy_16-03-09_74.txt
[INFO ] Kivy: v1.9.1
[INFO ] Python: v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO ] Factory: 179 symbols loaded
[INFO ] Image: Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] OSC: using <thread> for socket
[INFO ] Window: Provider: sdl2
[INFO ] GL: GLEW initialization succeeded
[INFO ] GL: OpenGL version <b'3.3.0'>
[INFO ] GL: OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] GL: OpenGL renderer <b'GeForce 210/PCIe/SSE2'>
[INFO ] GL: OpenGL parsed version: 3, 3
[INFO ] GL: Shading version <b'3.30 NVIDIA via Cg compiler'>
[INFO ] GL: Texture max size <8192>
[INFO ] GL: Texture max units <32>
[INFO ] Window: auto add sdl2 input provider
[INFO ] Window: virtual keyboard not allowed, single mode, not docked
[INFO ] Text: Provider: sdl2
[WARNING ] stderr: Traceback (most recent call last):
[WARNING ] stderr: File "<string>", line 58, in <module>
[WARNING ] stderr: File "C:\EZS-2G\CETAcalApp\dist\CETA-Cal\cls\plotting.py", line 5, in <module>
[WARNING ] stderr: import matplotlib.pyplot as plt
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\pyplot.py", line 36, in <module>
[WARNING ] stderr: from matplotlib.figure import Figure, figaspect
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\figure.py", line 40, in <module>
[WARNING ] stderr: from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\__init__.py", line 4, in <module>
[WARNING ] stderr: from ._subplots import *
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\_subplots.py", line 10, in <module>
[WARNING ] stderr: from matplotlib.axes._axes import Axes
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\axes\_axes.py", line 22, in <module>
[WARNING ] stderr: import matplotlib.dates as _ # <-registers a date unit converter
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\matplotlib\dates.py", line 130, in <module>
[WARNING ] stderr: import dateutil.parser
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\parser.py", line 43, in <module>
[WARNING ] stderr: from . import tz
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\__init__.py", line 1, in <module>
[WARNING ] stderr: from .tz import *
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\tz.py", line 17, in <module>
[WARNING ] stderr: from .__init__ import tzname_in_python2
[WARNING ] stderr: File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
[WARNING ] stderr: exec(bytecode, module.__dict__)
[WARNING ] stderr: File "C:\Python34\lib\site-packages\dateutil\tz\__init__.py", line 1, in <module>
[WARNING ] stderr: from .tz import *
[WARNING ] stderr: ImportError: No module named 'dateutil.tz.__init__.tz'
I had the same problem (also on windows 7 and Python 3.4 and python-dateutil version 2.5). I did some reading e.g. at https://github.com/dateutil/dateutil/pull/202#issuecomment-192352290. Like you I tried to make some amendments to the dateutil package, but in the end I simply reverted the package to the previous version with pip i.e. 'pip install python-dateutil==2.4.2' and that resolved the issue for me.
I had similar problem. Since everything worked I found a workaround using:
import warnings
warnings.filterwarnings("ignore", category=UserWarning)
Related
I am trying to deploy my own django app on google cloud.
I'm following this documentation
by Google Cloud to deploy the app.
I have changed the settings.py file of my app according to the settings.py file of settings.py file of the sample app provided by google and I think this issue is due to some mistake in that setting file or maybe something else. I'm not able to solve the error after lots of attempts.
please help me thank you
Settings.py file
from pathlib import Path
import os
import io
from urllib.parse import urlparse
import environ
from google.cloud import secretmanager
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# [START gaestd_py_django_secret_config]
env = environ.Env(DEBUG=(bool, False))
env_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(env_file):
# Use a local secret file, if provided
env.read_env(env_file)
# [START_EXCLUDE]
elif os.getenv("TRAMPOLINE_CI", None):
# Create local settings if running with CI, for unit testing
placeholder = (
f"SECRET_KEY=a\n"
f"DATABASE_URL=sqlite://{os.path.join(BASE_DIR, 'db.sqlite3')}"
)
env.read_env(io.StringIO(placeholder))
# [END_EXCLUDE]
elif os.environ.get("GOOGLE_CLOUD_PROJECT", None):
# Pull secrets from Secret Manager
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
client = secretmanager.SecretManagerServiceClient()
settings_name = os.environ.get("SETTINGS_NAME", "django_settings")
name = f"projects/{project_id}/secrets/{settings_name}/versions/latest"
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
env.read_env(io.StringIO(payload))
else:
raise Exception("No local .env or GOOGLE_CLOUD_PROJECT detected. No secrets found.")
# [END gaestd_py_django_secret_config]
SECRET_KEY = env("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env("DEBUG")
# [START gaestd_py_django_csrf]
# SECURITY WARNING: It's recommended that you use this when
# running in production. The URL will be known once you first deploy
# to App Engine. This code takes the URL and converts it to both these settings formats.
APPENGINE_URL = env("APPENGINE_URL", default=None)
if APPENGINE_URL:
# Ensure a scheme is present in the URL before it's processed.
if not urlparse(APPENGINE_URL).scheme:
APPENGINE_URL = f"https://{APPENGINE_URL}"
ALLOWED_HOSTS = [urlparse(APPENGINE_URL).netloc]
CSRF_TRUSTED_ORIGINS = [APPENGINE_URL]
SECURE_SSL_REDIRECT = True
else:
ALLOWED_HOSTS = ["*"]
# [END gaestd_py_django_csrf]
# Application definition
INSTALLED_APPS = [
'portpolio.apps.PortpolioConfig',
'CRblogs.apps.CrblogsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_social_share',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'crrathod.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'crrathod.wsgi.application'
# Database
# [START db_setup]
# [START gaestd_py_django_database_config]
# Use django-environ to parse the connection string
DATABASES = {"default": env.db()}
# If the flag as been set, configure to use proxy
if os.getenv("USE_CLOUD_SQL_AUTH_PROXY", None):
DATABASES["default"]["HOST"] = "127.0.0.1"
DATABASES["default"]["PORT"] = 8088
# [END gaestd_py_django_database_config]
# [END db_setup]
# Use a in-memory sqlite3 database when testing in CI systems
# TODO(glasnt) CHECK IF THIS IS REQUIRED because we're setting a val above
if os.getenv("TRAMPOLINE_CI", None):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
# STATICFILES_DIRS =[
# os.path.join(BASE_DIR, 'static')
# ]
# STATIC_ROOT = os.path.join(BASE_DIR,'assets')
STATIC_URL = 'static/'
MEDIA_URL = '/media/'
if DEBUG:
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
else:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
Log file
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\grpc_helpers.py", line 72, in error_remapped_callable
return callable_(*args, **kwargs)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\grpc\_channel.py", line 946, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "Permission denied on resource project my-portfolio-361305."
debug_error_string = "{"created":"#1662731782.139000000","description":"Error received from peer ipv6:[2404:6800:4009:825::200a]:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Permission denied on resource project my-portfolio-361305.","grpc_status":7}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\core\management\__init__.py", line 386, in execute
settings.INSTALLED_APPS
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 87, in __getattr__
self._setup(name)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 74, in _setup
self._wrapped = Settings(settings_module)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\django\conf\__init__.py", line 183, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\LONAR\AppData\Local\Programs\Python\Python38\lib\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 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\crrathod\settings.py", line 50, in <module>
payload = client.access_secret_version(name=name).payload.data.decode("UTF-8")
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\cloud\secretmanager_v1\services\secret_manager_service\client.py", line 1440, in access_secret_version
response = rpc(
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\gapic_v1\method.py", line 154, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\retry.py", line 283, in retry_wrapped_func
return retry_target(
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\retry.py", line 190, in retry_target
return target()
File "C:\Program Files (x86)\Google\Cloud SDK\Portfolio-blog\env\lib\site-packages\google\api_core\grpc_helpers.py", line 74, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.PermissionDenied: 403 Permission denied on resource project my-portfolio-361305. [links {
description: "Google developer console API key"
url: "https://console.developers.google.com/project/ my-portfolio-361305/apiui/credential"
}
, reason: "CONSUMER_INVALID"
domain: "googleapis.com"
metadata {
key: "service"
value: "secretmanager.googleapis.com"
}
metadata {
key: "consumer"
value: "projects/ my-portfolio-361305"
}
]
I just shifted from one problem to another. I did some changes here. I have removed space after = from this cmd set GOOGLE_CLOUD_PROJECT=my-portfolio-361305 previously I was using set GOOGLE_CLOUD_PROJECT= my-portfolio-361305 this cmd. Now I have also removed space after = in secret manager file as I read that in some solutions for my new problem Error in deploying Django app on Google cloud using appengine "django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable".
I got a solution to that problem as well by running set SECRET_KEY=my_secret_key_value
But now got a new problem as after running python manage.py makemigrations
as
RuntimeWarning: Got an error checking a consistent migration history performed for >database connection 'default': connection to server at "127.0.0.1", port 5432>failed: FATAL: password authentication failed for user "CRRathod"
warnings.warn(
No changes detected
It seems here as I have entered the wrong password. But I check that as well
Thank You!
I have an issue on debugging a Kivy project with PyCahrm.
I'm on Win 10 x64.
Config version 1:
Python: 3.7.9 x64
Kivy: 2.0.0
PyCharm (Community Edition): 2022.1.1
Config version 2:
Python: 3.10.4 x64
Kivy: 2.1.0
PyCharm (Community Edition): 2022.1.1
First, I need to say that with Config version 1 I worked bevor and still have no problems.
What I did:
installed Python 3.10
created new venv
installed Kivy
installed other for my project required packages
added Python Interpreter to the Project in PyCharm
edited Run/Debug configuration to new interpreter in PyCharm
If I just run the project, it works like I expected without any errors, but if I try to debug it, I always get an Exception.
With MS VSCode I'm able to debug the Project, so I assume there is something with my configuration in PyCharm.
This is my console Output while debugging in PyCharm:
[WARNING] [Config ] Older configuration version detected (21 instead of 24)
[WARNING] [Config ] Upgrading configuration in progress.
[DEBUG ] [Config ] Upgrading from 21 to 22
[DEBUG ] [Config ] Upgrading from 22 to 23
[DEBUG ] [Config ] Upgrading from 23 to 24
[INFO ] [Logger ] Record log in C:\Users\x\.kivy\logs\kivy_22-05-30_23.txt
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.2
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.1
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.4.5
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "C:\Projects\My Project\venv310\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Projects\My Project\venv310\Scripts\python.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[DEBUG ] [Cache ] register <kv.resourcefind> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[DEBUG ] [GL ] available extensions: b'GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_blend_color GL_EXT_abgr GL_EXT_texture3D GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_SGIS_texture_edge_clamp GL_SGIS_generate_mipmap GL_EXT_draw_range_elements GL_SGIS_texture_lod GL_EXT_rescale_normal GL_EXT_packed_pixels GL_EXT_texture_edge_clamp GL_EXT_separate_specular_color GL_ARB_multitexture GL_ARB_map_buffer_alignment GL_ARB_conservative_depth GL_EXT_texture_env_combine GL_EXT_bgra GL_EXT_blend_func_separate GL_EXT_secondary_color GL_EXT_fog_coord GL_EXT_texture_env_add GL_ARB_texture_cube_map GL_ARB_transpose_matrix GL_ARB_internalformat_query GL_ARB_internalformat_query2 GL_ARB_texture_env_add GL_IBM_texture_mirrored_repeat GL_ARB_texture_mirrored_repeat GL_EXT_multi_draw_arrays GL_SUN_multi_draw_arrays GL_NV_blend_square GL_ARB_texture_compression GL_3DFX_texture_compression_FXT1 GL_EXT_texture_filter_anisotropic GL_ARB_texture_border_clamp GL_ARB_point_parameters GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_EXT_texture_compression_s3tc GL_ARB_shadow GL_ARB_window_pos GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_ARB_vertex_program GL_EXT_texture_rectangle GL_ARB_fragment_program GL_EXT_stencil_two_side GL_ATI_separate_stencil GL_ARB_vertex_buffer_object GL_EXT_texture_lod_bias GL_ARB_occlusion_query GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_non_power_of_two GL_ARB_vertex_shader GL_NV_texgen_reflection GL_ARB_point_sprite GL_ARB_fragment_program_shadow GL_EXT_blend_equation_separate GL_ARB_depth_texture GL_ARB_texture_rectangle GL_ARB_draw_buffers GL_ARB_color_buffer_float GL_ARB_half_float_pixel GL_ARB_texture_float GL_ARB_pixel_buffer_object GL_ARB_texture_barrier GL_EXT_framebuffer_object GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_ARB_occlusion_query2 GL_EXT_draw_buffers2 GL_WIN_swap_hint GL_EXT_texture_sRGB GL_ARB_multisample GL_EXT_packed_float GL_EXT_texture_shared_exponent GL_ARB_texture_rg GL_ARB_texture_compression_rgtc GL_NV_conditional_render GL_ARB_texture_swizzle GL_EXT_texture_swizzle GL_ARB_texture_gather GL_ARB_sync GL_ARB_cl_event GL_ARB_framebuffer_sRGB GL_EXT_packed_depth_stencil GL_ARB_depth_buffer_float GL_EXT_transform_feedback GL_ARB_transform_feedback2 GL_ARB_draw_indirect GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_ARB_framebuffer_object GL_ARB_framebuffer_no_attachments GL_EXT_texture_array GL_EXT_texture_integer GL_ARB_map_buffer_range GL_ARB_texture_buffer_range GL_EXT_texture_snorm GL_ARB_blend_func_extended GL_INTEL_performance_query GL_ARB_copy_buffer GL_ARB_sampler_objects GL_NV_primitive_restart GL_ARB_seamless_cube_map GL_ARB_seamless_cubemap_per_texture GL_ARB_uniform_buffer_object GL_ARB_depth_clamp GL_ARB_vertex_array_bgra GL_ARB_shader_bit_encoding GL_ARB_draw_buffers_blend GL_ARB_geometry_shader4 GL_EXT_geometry_shader4 GL_ARB_texture_query_lod GL_ARB_explicit_attrib_location GL_ARB_draw_elements_base_vertex GL_EXT_shader_integer_mix GL_ARB_instanced_arrays GL_ARB_base_instance GL_ARB_fragment_coord_conventions GL_EXT_gpu_program_parameters GL_ARB_texture_buffer_object_rgb32 GL_ARB_compatibility GL_ARB_texture_rgb10_a2ui GL_ARB_texture_multisample GL_ARB_vertex_type_2_10_10_10_rev GL_ARB_vertex_type_10f_11f_11f_rev GL_ARB_timer_query GL_EXT_timer_query GL_ARB_tessellation_shader GL_ARB_vertex_array_object GL_ARB_provoking_vertex GL_ARB_sample_shading GL_ARB_texture_cube_map_array GL_EXT_gpu_shader4 GL_ARB_gpu_shader5 GL_ARB_gpu_shader_fp64 GL_INTEL_fragment_shader_ordering GL_ARB_fragment_shader_interlock GL_ARB_clip_control GL_ARB_shader_subroutine GL_ARB_transform_feedback3 GL_ARB_get_program_binary GL_ARB_separate_shader_objects GL_ARB_shader_precision GL_ARB_vertex_attrib_64bit GL_ARB_viewport_array GL_ARB_transform_feedback_instanced GL_ARB_compressed_texture_pixel_storage GL_ARB_shader_atomic_counters GL_ARB_shading_language_packing GL_ARB_shader_image_load_store GL_ARB_shading_language_420pack GL_ARB_texture_storage GL_EXT_texture_storage GL_ARB_compute_shader GL_ARB_vertex_attrib_binding GL_ARB_texture_view GL_ARB_fragment_layer_viewport GL_ARB_multi_draw_indirect GL_ARB_program_interface_query GL_ARB_shader_image_size GL_ARB_shader_storage_buffer_object GL_ARB_texture_storage_multisample GL_ARB_buffer_storage GL_AMD_vertex_shader_layer GL_AMD_vertex_shader_viewport_index GL_ARB_query_buffer_object GL_EXT_polygon_offset_clamp GL_ARB_clear_texture GL_ARB_texture_mirror_clamp_to_edge GL_ARB_debug_output GL_ARB_enhanced_layouts GL_KHR_debug GL_ARB_arrays_of_arrays GL_ARB_texture_query_levels GL_ARB_invalidate_subdata GL_ARB_clear_buffer_object GL_INTEL_map_texture GL_ARB_texture_compression_bptc GL_ARB_ES2_compatibility GL_ARB_ES3_compatibility GL_ARB_robustness GL_ARB_robust_buffer_access_behavior GL_EXT_texture_sRGB_decode GL_ARB_copy_image GL_KHR_blend_equation_advanced GL_EXT_direct_state_access GL_ARB_stencil_texturing GL_ARB_texture_stencil8 GL_ARB_explicit_uniform_location GL_ARB_multi_bind GL_ARB_indirect_parameters '
[DEBUG ] [GL ] glShaderBinary is not available
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.3.0 - Build 20.19.15.5126'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics 4600'>
[INFO ] [GL ] OpenGL parsed version: 4, 3
[INFO ] [GL ] Shading version <b'4.30 - Build 20.19.15.5126'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load <C:\Projects\My Project\venv310\lib\site-packages\kivy\data\glsl\default.png>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[WARNING] Both Window.minimum_width and Window.minimum_height must be bigger than 0 for the size restriction to take effect.
[INFO ] [Text ] Provider: sdl2
[INFO ] [Clipboard ] Provider: winctypes
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:\Projects\My Project\src\My_App.py", line 27, in <module>
import doctodb.sql_utils as slq_utils # sqlite3 & Co.
File "C:\Projects\My Project\src\doctodb\sql_utils.py", line 14, in <module>
import my_globals
File "C:\Projects\My Project\src\my_globals.py", line 12, in <module>
from kivy.app import App
File "C:\Projects\My Project\venv310\lib\site-packages\kivy\app.py", line 414, in <module>
from os.path import dirname, join, exists, sep, expanduser, isfile
ImportError: cannot import name 'sep' from 'ntpath' (C:\Python\Python310\lib\ntpath.py)
Exception ignored in: <module 'threading' from 'C:\\Python\\Python310\\lib\\threading.py'>
Traceback (most recent call last):
File "C:\Python\Python310\lib\threading.py", line 1560, in _shutdown
lock.acquire()
KeyboardInterrupt:
Process finished with exit code 1
Any idea what could I try to solve this?
this is my first question at Stack overflow. I have been learning Python for about a month and Django for two weeks. I tried to run a second server on my MacBook Pro and then had these problems.(the error messages from my terminal below) The second server included some other applications including Pihole. I deleted the second server files and re-booted, problem solved! The next thing was that I tried editing my Views.py file in Django and then the same error message came back when I re-booted my Django server in the virtual environment folder.
See errors below:
mymac#michaels-MacBook-Pro mfdw_root % python manage.py runserver
Traceback (most recent call last):
File "/Users/mymac/Desktop/mfdw_project/mfdw_root/manage.py", line 22, in <module>
main()
File "/Users/mymac/Desktop/mfdw_project/mfdw_root/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/conf/__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/conf/__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 786, in exec_module
File "<frozen importlib._bootstrap_external>", line 923, in get_code
File "<frozen importlib._bootstrap_external>", line 853, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/mymac/Desktop/mfdw_project/mfdw_root/mfdw_site/settings.py", line 123
'DIRS': [BASE_DIR / 'mfdw_site/templates'],
^
SyntaxError: illegal target for annotation
end of errors********
This is my first question at Stack Overflow and I am very uncertain right now if I will ever get my server running again on my MacBook Pro with Python 3.9.0 and Django 3.1.3
This is the error I get above, and I can't connect to 127.0.0.1 , the localhost on my MacBook Pro.
Please try and give me a clue as to how to proceed. I have been following the lessons of djangobook.com .
Below is my settings.py file:
"""
Django settings for mfdw_site project.
Generated by 'django-admin startproject' using Django 3.1.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '# secret key goes here, it is present in actual code'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'pages.apps.PagesConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mfdw_site.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'mfdw_site/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'mfdw_site.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
'DIRS': [BASE_DIR / 'mfdw_site/templates'],
STATICFILES_DIRS = [BASE_DIR / 'mfdw_site/static')]
Also, is there a path problem with my Django installation? I am running on a MacBook Pro which is properly updated to use Python 3.9 . I think it might have something to do with this part of the errors:
"/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
Does this seem reasonable? The flagged code in settings.py occurs on line 123.
Also it looks to me like python 3.9 has an included django installation which is confused via path with the mfdw_project files.
Am I right and what should I do about it?
Please read the error carefully, it says that your settings file is misconfigured on line 123 and gives you the line that is offending with the ^ as a sign on where it happens:
'DIRS': [BASE_DIR / 'mfdw_site/templates'],
^
and it says there is a syntax error, so you can tell that the problem is you wrote something not according to the syntax of python.
According to this, you should check what is going on on the line before this line (line 122), check what happens if you put this line in comment (with #), it will either find another error on the next line, find an error somewhere later or run smoothly.
If it finds an error on the next line, you can check what you did wrong on the line before this one (line 122).
If it finds an error somewhere later on you can understand the problem is with the actual line (line 122) and it's probably the / you have there, a list sepperator is comma (,), not /...
Edit:
First, thanks for adding the settings file, it helps to find the error after we know what to look for.
The offending line is 123 and it looks like this:
'DIRS': [BASE_DIR / 'mfdw_site/templates'],
This has 3 problems:
The 'DIRS' shouldn't be a string, it should be a variable, so remove the '.
The line shouldn't have a colon, this is not a dictionary or a function definition.
I understand that you want to have the path as BASE_DIR/mfdw_site/templates, assuming so, it can be [f'{BASE_DIR}/mfdw_site/templates'] and a few other options, but this is the easiest
i am new to django. I am deploying my simple web application on heroku server via github. But when i deploy it, my build going to fail and it show this error on heroku logs:
-----> Python app detected
-----> Installing python-3.8.3
-----> Installing pip
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting appdirs==1.4.4
Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting asgiref==3.2.10
Downloading asgiref-3.2.10-py3-none-any.whl (19 kB)
Collecting distlib==0.3.1
Downloading distlib-0.3.1-py2.py3-none-any.whl (335 kB)
Collecting Django==3.0.8
Downloading Django-3.0.8-py3-none-any.whl (7.5 MB)
Collecting django-filter==2.3.0
Downloading django_filter-2.3.0-py3-none-any.whl (73 kB)
Collecting filelock==3.0.12
Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Collecting gunicorn==20.0.4
Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
Collecting Pillow==7.2.0
Downloading Pillow-7.2.0-cp38-cp38-manylinux1_x86_64.whl (2.2 MB)
Collecting pytz==2020.1
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
Collecting six==1.15.0
Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting sqlparse==0.3.1
Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
Collecting virtualenv==20.0.26
Downloading virtualenv-20.0.26-py2.py3-none-any.whl (4.9 MB)
Collecting virtualenvwrapper-win==1.2.6
Downloading virtualenvwrapper-win-1.2.6.tar.gz (21 kB)
Collecting whitenoise==5.1.0
Downloading whitenoise-5.1.0-py2.py3-none-any.whl (19 kB)
Building wheels for collected packages: virtualenvwrapper-win
Building wheel for virtualenvwrapper-win (setup.py): started
Building wheel for virtualenvwrapper-win (setup.py): finished with status 'done'
Created wheel for virtualenvwrapper-win: filename=virtualenvwrapper_win-1.2.6-py3-none-any.whl size=18609 sha256=2894b9f0d8294f17c34d3498acb2ec9baba93dd1039a36a8e44c1252d8d2bb41
Stored in directory: /tmp/pip-ephem-wheel-cache-lqj2a4ec/wheels/66/25/f7/f4b3539b1cc86289c4e24e637c09a39f8f2ab6de61928f0be1
Successfully built virtualenvwrapper-win
Installing collected packages: appdirs, asgiref, distlib, pytz, sqlparse, Django, django-filter, filelock, gunicorn, Pillow, six, virtualenv, virtualenvwrapper-win, whitenoise
Successfully installed Django-3.0.8 Pillow-7.2.0 appdirs-1.4.4 asgiref-3.2.10 distlib-0.3.1 django-filter-2.3.0 filelock-3.0.12 gunicorn-20.0.4 pytz-2020.1 six-1.15.0 sqlparse-0.3.1 virtualenv-20.0.26 virtualenvwrapper-win-1.2.6 whitenoise-5.1.0
-----> $ python CommonModules/manage.py collectstatic --noinput
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
import psycopg2 as Database
ModuleNotFoundError: No module named 'psycopg2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "CommonModules/manage.py", line 21, in <module>
main()
File "CommonModules/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute
django.setup()
File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/app/.heroku/python/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/app/.heroku/python/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 "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/app/.heroku/python/lib/python3.8/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/base.py", line 121, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/models/options.py", line 208, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 207, in __getitem__
backend = load_backend(db['ENGINE'])
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/app/.heroku/python/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 29, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
! Error while running '$ python CommonModules/manage.py collectstatic --noinput'.
See traceback above for details.
You may need to update application code to resolve this error.
Or, you can disable collectstatic for this application:
$ heroku config:set DISABLE_COLLECTSTATIC=1
https://devcenter.heroku.com/articles/django-assets
! Push rejected, failed to compile Python app.
! Push failed
My settings.py file in django project is:
"""
Django settings for common project.
Generated by 'django-admin startproject' using Django 3.0.8.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '***************************************************'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['common-module.herokuapp.com','127.0.0.1']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'user'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'common.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'common.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'common',
'USER':'postgres',
'PASSWORD':'****',
'HOST':'localhost'
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
# STATIC_ROOT = os.path.normpath(os.path.join(BASE_DIR, 'staticfiles'))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
My requirements.txt file:
appdirs==1.4.4
asgiref==3.2.10
distlib==0.3.1
Django==3.0.8
django-filter==2.3.0
filelock==3.0.12
gunicorn==20.0.4
Pillow==7.2.0
psycopg2==2.8.5
psycopg2-binary==2.8.5
pytz==2020.1
six==1.15.0
sqlparse==0.3.1
virtualenv==20.0.26
virtualenvwrapper-win==1.2.6
whitenoise==5.1.0
Can anyone told me where i am doing wrong. And the solution to successfully deploy this app on heroku.
I installed kivy with:
sudo apt-get install python3-kivy
When I run a simple hello world button program from the terminal, it does not display a window, but it doesn't show an error message either. What should I do?
my code:
import kivy
from kivy.app import App
from kivy.uix.button import Button
class Sample(App):
def build(self):
return Button(text='Hello World')
Sample().run()
P.S. Python 3.6.5, kivy 1.9.1
Edit: as #khaled khalil suggested, i tried the solution.
Terminal output:
[INFO ] [Logger ] Record log in /home/shamildacoder/.kivy/logs/kivy_18-07-18_1.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0]
[INFO ] [Factory ] 179 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=None
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600
[INFO ] [Text ] Provider: sdl2
[DEBUG ] [App ] Loading kv <./hi.kv>
[DEBUG ] [App ] kv <./hi.kv> not found
[DEBUG ] [Window ] Ignored <egl_rpi> (import error)
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[DEBUG ] [Window ] Ignored <x11> (import error)
[CRITICAL] [Window ] Unable to find any valuable Window provider at all!
egl_rpi - ImportError: cannot import name 'bcm'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/usr/lib/python3/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
from kivy.lib.vidcore_lite import bcm, egl
sdl2 - TypeError: expected bytes, str found
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 67, in core_select_lib
cls = cls()
File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 138, in __init__
super(WindowSDL, self).__init__()
File "/usr/lib/python3/dist-packages/kivy/core/window/__init__.py", line 722, in __init__
self.create_window()
File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 237, in create_window
self.fullscreen, resizable, state)
File "kivy/core/window/_window_sdl2.pyx", line 94, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2204)
x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
File "/usr/lib/python3/dist-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
[CRITICAL] [App ] Unable to get a Window, abort.
Exception ignored in: 'kivy.properties.dpi2px'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/kivy/utils.py", line 513, in __get__
retval = self.func(inst)
File "/usr/lib/python3/dist-packages/kivy/metrics.py", line 175, in dpi
EventLoop.ensure_window()
File "/usr/lib/python3/dist-packages/kivy/base.py", line 126, in ensure_window
sys.exit(1)
SystemExit: 1
[CRITICAL] [App ] Unable to get a Window, abort.