I am trying to create an installer for a django website that uses the django-omnibus module.
My Pyinstaller command:
pyinstaller --name djangosite manage.py
The Pyinstaller command runs to completion.
Trying to run the web server using
djangosite.exe runserver localhost:8000
I get the following error:
Traceback (most recent call last):
File "<string>", line 10, in <module>
File "django\core\management\__init__.py", line 338, in execute_from_command_line
File "django\core\management\__init__.py", line 312, in execute
File "django\__init__.py", line 18, in setup
File "django\apps\registry.py", line 85, in populate
File "django\apps\config.py", line 86, in create
File "importlib\__init__.py", line 37, in import_module
File "c:\users\USERNAME\appdata\local\temp\pip-build-vxcefe\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
File "omnibus\__init__.py", line 3, in <module>
File "pkg_resources\__init__.py", line 561, in get_distribution
File "pkg_resources\__init__.py", line 441, in get_provider
File "pkg_resources\__init__.py", line 962, in require
File "pkg_resources\__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The 'django-omnibus' distribution was not found and is required by the application manage returned -1
If I remove all django-omnibus code, the site works fine (except for the my websocket functionality obviously). Any ideas? Thanks.
I needed to add a hook.py file for django-omnibus and add the --additional-hooks-dir=. flag to the pyinstaller command.
hook-omnibus.py
from PyInstaller.utils.hooks import copy_metadata, collect_data_files
datas = copy_metadata('django-omnibus')
datas += collect_data_files('omnibus')
Similar answer here:
https://github.com/pyinstaller/pyinstaller/issues/1713
I know this is a late reply, but I had a similar issue with django-user-accounts - pkg_resources.DistributionNotFound: The 'django-user-accounts' distribution was not found
I was directed here when searching for a fix. I solved the issue with the following addition to settings.py - hopefully helps someone else.
INSTALLED_APPS = [
...
'django.contrib.sites',
...
]
Related
so I've created a virtual environment in my iterm2 window. this is the ques I asked earlier which has not been solved yet and my app is not running is alias modeso i tried to do the whole process again but it was showing error with plistlib so that was fixed by this answer I tried this whole process again which means I did this all this before but my app was not working so i deleted my py2app and some venv's got deleted to I downloaded miniconda3 again and then it was working until it comes to running the app even in alias mode . but I continued and deleted the dist and build and when I executed
python setup.py py2app but then i got this error
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/Users/divyabansal/divya/lib/python3.7/site-packages/setuptools/__init__.py", line
145, in setup
return distutils.core.setup(**attrs)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 966, in
run_commands
self.run_command(cmd)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 985, in
run_command
cmd_obj.run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 756,
in run
self._run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 966,
in _run
self.run_normal()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1074,
in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1384,
in create_binaries
mm.mm.run_file(runtime)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/macholib/MachOGraph.py", line 89,
in run_file
raise ValueError("%r does not exist" % (pathname,))
ValueError: '/Users/divyabansal/miniconda3/lib/libpython3.7.dylib'
does not exist
please help me with this problem
Thank You!
This problem can often be fixed by creating a symlink, see here for more.
ln -s /path/to/lib/libpython3.7m.dylib /path/to/lib/libpython3.7.dylib
For the above command replace it with your own path.
I tried various ways (every solution mentioned in the stackoverflow) to solve the problem but still the problems continues.
When I run : "python manage.py migrate" the following error is shown
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv
self.execute(*args, **cmd_options)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 353, in execute
self.check()
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check
include_deployment_checks=include_deployment_checks,
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/core/checks/database.py", line 9, in check_database_backends
for conn in connections.all():
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 226, in all
return [self[alias] for alias in self]
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Manish/Projects/Websites/SanirTVNetwork/SanirTV/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
Then I tried: "pip install mysql-python" as per the suggestions in the stackoverflow similar questions. I got the following error
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/7_/cx21vvvn5cqdypfndc7j_jl80000gn/T/pip-build-JjMQeR/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7_/cx21vvvn5cqdypfndc7j_jl80000gn/T/pip-build-JjMQeR/mysql-python/
I even tried: "brew install mysql-connector-c" but the same error starts to come.
I finally did it:
First I installed the command line developer tools required by running the following code inside the virtualenv
$ xcode-select --install
Then I installed MySQL-python by using the following code
pip install MySQL-python
Finally I migrated the database using:
python manage.py migrate
It worked without any errors
The main problem with the error was that I didn't installed the command line developer tools required.
I've just recently started played around with web application development using Django and now got to Django-Q for async tasks.
I followed this tutorial up to slide 13. Unfortunately then, when I try to run python manage.py qcluster I get these error messages:
(djangoq_tut) D:\Code\Python\DjangoQ_Tutorial\djangoq_demo>python manage.py qcluster
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
utility.execute()
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django_q\management\commands\qcluster.py", line 22, in handle
q.start()
File "D:\Code\Python\DjangoQ_Tutorial\djangoq_tut\lib\site-packages\django_q\cluster.py", line 57, in start
self.sentinel.start()
File "c:\program files (x86)\python35-32\Lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "c:\program files (x86)\python35-32\Lib\multiprocessing\context.py", line 212, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "c:\program files (x86)\python35-32\Lib\multiprocessing\context.py", line 313, in _Popen
return Popen(process_obj)
File "c:\program files (x86)\python35-32\Lib\multiprocessing\popen_spawn_win32.py", line 66, in __init__
reduction.dump(process_obj, to_child)
File "c:\program files (x86)\python35-32\Lib\multiprocessing\reduction.py", line 59, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: can't pickle _thread.lock objects
(djangoq_tut) D:\Code\Python\DjangoQ_Tutorial\djangoq_demo>Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files (x86)\python35-32\Lib\multiprocessing\spawn.py", line 100, in spawn_main
new_handle = steal_handle(parent_pid, pipe_handle)
File "c:\program files (x86)\python35-32\Lib\multiprocessing\reduction.py", line 86, in steal_handle
_winapi.DUPLICATE_SAME_ACCESS | _winapi.DUPLICATE_CLOSE_SOURCE)
PermissionError: [WinError 5] Access is denied
I'm using a Windows 7 machine and Python 3.5.1 (32 bit) with following requirements:
appdirs==1.4.3
arrow==0.10.0
blessed==1.14.1
Django==1.9
django-picklefield==0.3.2
django-q==0.7.18
future==0.16.0
packaging==16.8
pyparsing==2.2.0
python-dateutil==2.6.0
six==1.10.0
wcwidth==0.1.7
I tried looking up the source of the error, it looks to me as it might not be exclusively related to Django or Django-Q. Other than that I don't really understand what it means.
Also tried with Python 2.7.12, outside of a virtualenv, there I get a TypeError: can't pickle _thread.lock objects, which I don't really get either.
Any ideas how to solve this?
[Edit]
After experimenting with a DjangoQ alternative - Celery - I as able to recreate the problem:
The same error occurs if using Celery 4.0.2, but not with Celery 3.1.25
I still haven't figured out how to fix this, but decided to stick to Celery for the time being, since it kinda works...
Install the latest version with pip:
$ pip install django-q
Add django_q to INSTALLED_APPS in your projects settings.py:
INSTALLED_APPS = (
# other apps
'django_q',
)
Run Django migrations to create the database tables:
$ python manage.py migrate
Choose a message broker , configure it and install the appropriate client library.
Run Django Q cluster in order to handle tasks async:
$ python manage.py qcluster
I tried installing django-utils from source code from github and using pip. The installation goes fine however the queue_command does not work within my django app.
So as suggested in the docs, I tried running `python setup.py test' and I get the following error. I have not idea how to fix this. I am running from within virtualenv on mac snow leopard.
Any suggestions? Thank you.
running test
running egg_info
writing djutils.egg-info/PKG-INFO
writing top-level names to djutils.egg-info/top_level.txt
writing dependency_links to djutils.egg-info/dependency_links.txt
reading manifest file 'djutils.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'LICENSE.txt'
writing manifest file 'djutils.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 33, in <module>
tests_require=['pygments', 'PIL>=0.1.5', 'httplib2'],
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 121, in run
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 101, in with_project_on_sys_path
File "build/bdist.linux-i686/egg/setuptools/command/test.py", line 130, in run_tests
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
self.createTests()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
self.module)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 128, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/Users/miki725/Development/libs/django-utils/runtests.py", line 43, in <module>
from django.test.simple import run_tests
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/test/__init__.py", line 5, in <module>
from django.test.client import Client, RequestFactory
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/test/client.py", line 27, in <module>
from django.db import close_connection
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/miki725/Development/Django/lib/python2.7/site-packages/django/db/utils.py", line 51, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'sqlite3' isn't an available database backend.
Try using django.db.backends.sqlite3 instead.
Error was: No module named base
What version of Django are you running? 1.3 deprecated the old-style way of specifying databases, for example, using just 'sqlite3'. You now must specify the entire import path, i.e. django.db.backends.sqlite3.
However, I was pretty sure that 1.3 still let you use the old-style way and simply fussed at you, warning that it's deprecated. Perhaps I was wrong though. If you're running off trunk, then, it's almost certainly fully deprecated, which makes that error a little more understandable.
The long and short is that since the last update of django-utils was back in 2009, it's effectively dead, and Django has moved on.
Open your settings.py
Replace 'ENGINE': 'sqlite3', with 'ENGINE': 'django.db.backends.sqlite3',
Save
Try again.
Need some help starting up the djangoappengine testapp.I followed the instructions at http://www.allbuttonspressed.com/projects/djangoappengine, but when I run ./manage.py runserver . while in the project directory I get the following error:
WARNING 2011-03-24 12:23:21,994 datastore_file_stub.py:657] Could not read datastore
data from /media/disk/Projex/AppEngineApp/app/.gaedata/datastore
Error: option --rdbms_sqlite_path not recognized
Runs a development application server for an application.
manage.py [options] <application root>__
When I try and comment the ' 'rdbms_sqlite_path': os.path.join(DATA_ROOT, 'rdbms'),' line in app/djangoappengine/db/base.py I get the following error:
WARNING 2011-03-24 12:26:07,239 datastore_file_stub.py:657] Could not read datastore
data from /media/disk/Projex/AppEngineApp/app/.gaedata/datastore
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_manager(settings)
File "/media/disk/Projex/AppEngineApp/app/django/core/management/__init__.py", line 438,
in execute_manager
utility.execute()
File "/media/disk/Projex/AppEngineApp/app/django/core/management/__init__.py", line 379,
in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/media/disk/Projex/AppEngineApp/app/djangoappengine/management/commands/runserver.py",
line 94, in run_from_argv
start_dev_appserver(argv)
File
"/media/disk/Projex/AppEngineApp/app/djangoappengine/management/commands/runserver.py",
line 81, in start_dev_appserver
dev_appserver_main.main([progname] + args + [PROJECT_DIR])
File "/usr/local/gaepy/google/appengine/tools/dev_appserver_main.py", line 426, in main
static_caching=static_caching)
File "/usr/local/gaepy/google/appengine/tools/dev_appserver.py", line 3820, in
CreateServer
server = HTTPServerWithScheduler((serve_address, port), handler_class)
File "/usr/local/gaepy/google/appengine/tools/dev_appserver.py", line 3840, in __init__
request_handler_class)
File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
self.server_bind()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.6/SocketServer.py", line 411, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.gaierror: [Errno -5] No address associated with hostname
Anyone experienced this issue ?
You probably already solved this, but for future users:
The warning can have multiple causes:
data store is empty, in that case ignore
wrong permissions on the datastore files
data corruption issue
The error can be solved by updating djangoappengine
Update to the latest version of google app engine.