AWS: Unable to configure profiles in AWS - amazon-web-services

I had issues in accessing S3 buckets from EC2. I deleted both ~/.aws/config and ~/.aws/credentials files. Now, when I try to create the profiles again, I get this long list of exceptions:
$ aws configure --profile dev
Traceback (most recent call last): File "/usr/local/bin/aws", line
27, in
sys.exit(main()) File "/usr/local/bin/aws", line 23, in main
return awscli.clidriver.main() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 50, in main
return driver.main() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 176, in
main
parser = self._create_parser() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 157, in
_create_parser
command_table = self._get_command_table() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 91, in
_get_command_table
self._command_table = self._build_command_table() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 111, in
_build_command_table
command_object=self) File "/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
672, in emit
return self._events.emit(event_name, **kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 356,
in emit
return self._emitter.emit(aliased_event_name, **kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 228,
in emit
return self._emit(event_name, kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 211,
in _emit
response = handler(**kwargs) File "/usr/lib/python3/dist-packages/awscli/customizations/preview.py",
line 70, in mark_as_preview
service_name=original_command.service_model.service_name, File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 351, in
service_model
return self._get_service_model() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 368, in
_get_service_model
api_version = self.session.get_config_variable('api_versions').get( File
"/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
234, in get_config_variable
logical_name) File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 227, in get_config_variable
return provider.provide() File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 324, in provide
value = provider.provide() File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 383, in provide
config = self._session.get_scoped_config() File "/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
335, in get_scoped_config
raise ProfileNotFound(profile=profile_name) botocore.exceptions.ProfileNotFound: The config profile (dev) could
not be found [~] aws configure --profile dev Traceback (most recent
call last): File "/usr/local/bin/aws", line 27, in
sys.exit(main()) File "/usr/local/bin/aws", line 23, in main
return awscli.clidriver.main() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 50, in main
return driver.main() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 176, in
main
parser = self._create_parser() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 157, in
_create_parser
command_table = self._get_command_table() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 91, in
_get_command_table
self._command_table = self._build_command_table() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 111, in
_build_command_table
command_object=self) File "/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
672, in emit
return self._events.emit(event_name, **kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 356,
in emit
return self._emitter.emit(aliased_event_name, **kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 228,
in emit
return self._emit(event_name, kwargs) File "/usr/local/lib/python3.5/dist-packages/botocore/hooks.py", line 211,
in _emit
response = handler(**kwargs) File "/usr/lib/python3/dist-packages/awscli/customizations/preview.py",
line 70, in mark_as_preview
service_name=original_command.service_model.service_name, File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 351, in
service_model
return self._get_service_model() File "/usr/lib/python3/dist-packages/awscli/clidriver.py", line 368, in
_get_service_model
api_version = self.session.get_config_variable('api_versions').get( File
"/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
234, in get_config_variable
logical_name) File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 227, in get_config_variable
return provider.provide() File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 324, in provide
value = provider.provide() File "/usr/local/lib/python3.5/dist-packages/botocore/configprovider.py",
line 383, in provide
config = self._session.get_scoped_config() File "/usr/local/lib/python3.5/dist-packages/botocore/session.py", line
335, in get_scoped_config
raise ProfileNotFound(profile=profile_name) botocore.exceptions.ProfileNotFound: The config profile (dev) could
not be found

Its failing because you deleted those directories and like the error mentions, it can't find the profile.
You have to run:
$ aws configure

I manually updated ~/.aws/config file. This resolved the issue.

Related

ssl error with copying file in s3 server?

I tried to collect static files on the S3 Server for my Django project with the command :
python manage.py collectstatic
But It failed because of SSLError :
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\httpsession.py", line 414, in send
chunked=self._chunked(request.headers),
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\connectionpool.py", line 756, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\util\retry.py", line 507, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
raise value.with_traceback(tb)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\connectionpool.py", line 706, in urlopen
chunked=chunked,
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\connection.py", line 421, in connect
tls_in_tls=tls_in_tls,
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\util\ssl_.py", line 450, in ssl_wrap_socket
sock, context, tls_in_tls, server_hostname=server_hostname
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 423, in wrap_socket
session=session
File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 870, in _create
self.do_handshake()
File "C:\Users\Anthony\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)
During handling of the above exception, another exception occurred:
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:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 187, in handle
collected = self.collect()
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 114, in collect
handler(path, prefixed_path, storage)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 338, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 248, in delete_file
if self.storage.exists(prefixed_path):
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\storages\backends\s3boto3.py", line 469, in exists
self.connection.meta.client.head_object(Bucket=self.bucket_name, Key=name)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\client.py", line 395, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\client.py", line 712, in _make_api_call
operation_model, request_dict, request_context)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\client.py", line 731, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\endpoint.py", line 107, in make_request
return self._send_request(request_dict, operation_model)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\endpoint.py", line 184, in _send_request
success_response, exception):
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\endpoint.py", line 308, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\hooks.py", line 357, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\hooks.py", line 211, in _emit
response = handler(**kwargs)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 192, in __call__
if self._checker(**checker_kwargs):
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 266, in __call__
caught_exception)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 292, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 332, in __call__
caught_exception)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 232, in __call__
attempt_number, caught_exception)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\retryhandler.py", line 374, in _check_caught_exception
raise caught_exception
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\endpoint.py", line 249, in _do_get_response
http_response = self._send(request)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\endpoint.py", line 321, in _send
return self.http_session.send(request)
File "C:\Users\Anthony\Documents\website_django\venv\lib\site-packages\botocore\httpsession.py", line 432, in send
raise SSLError(endpoint_url=request.url, error=e)
botocore.exceptions.SSLError: SSL validation failed for https://kol-mevasser-content.s3.eu-west-3.amazonaws.com/static/favicon.ico [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)
So I tried to install certifi with pip install certifi but it didn't work.
How can I collect my static files into S3 Server with resolving this SSL Error ?
Here is in my settings.py file :
# (I voluntary put SECRET)
AWS_ACCESS_KEY_ID = "SECRET"
AWS_SECRET_ACCESS_KEY = "SECRET"
AWS_STORAGE_BUCKET_NAME = "SECRET"
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
AWS_S3_REGION_NAME = 'eu-west-3'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
Seems AWS_S3_VERIFY=False setting is what you desire
https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html

Failing basic AWS Glacier mocking using moto

I am trying to mock simple Glacier calls (creation and deletion of a Glacier vault) and can't find my way around this (despite being able to achieve such simple mocking with S3, creating a Bucket).
It seems that the mocking of Glacier simply isn't taken into account.
Code is as follows:
import boto3
from moto import mock_glacier
with mock_glacier():
glacier_resource = boto3.resource('glacier', region_name="fake-glacier-region")
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
And I get the following exception at vault creation:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/<...>/test_mock_glacier.py", line 9, in test_simplest
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 663, in _make_api_call
operation_model, request_dict, request_context)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 682, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
success_response, exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 256, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 343, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://glacier.fake-glacier-region.amazonaws.com/-/vaults/fake.glacier.name"
I am using boto3 v1.17.49 and moto v2.0.8 that I installed using python3.7 -m pip install 'moto[all]'
Providing a valid AWS region name leads to following exception:
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the CreateVault operation: The security token included in the request is invalid.
(while having set mock AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SECURITY_TOKEN, AWS_SESSION_TOKEN environment variables (with 'testing' as value) as stated in moto's README)
I turned out to be a bug where a Glacier vault can not contain a . in its name.
A fix is on its way (merged into master, to be released with version 2.0.9)
Quickfix was thus to change vaultName="fake.glacier.name" to vaultName="fakeGlacierName".

set_autocommit got an unexpected keyword argument 'force_begin_transaction_with_broken_autocommit'

I've just upgraded to Django 1.9, and I'm getting this error, which seems to exist entirely inside the django stack, when I run tests.
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/test/runner.py", line 482, in setup_databases
self.parallel, **kwargs
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/test/runner.py", line 726, in setup_databases
serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 70, in create_test_db
run_syncdb=True,
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 119, in call_command
return command.execute(*args, **defaults)
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 89, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/migrations/loader.py", line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 56, in ensure_schema
with self.connection.schema_editor() as editor:
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 84, in __enter__
self.atomic.__enter__()
File "~/.virtualenvs/env/lib/python2.7/site-packages/django/db/transaction.py", line 184, in __enter__
connection.set_autocommit(False, force_begin_transaction_with_broken_autocommit=True)
TypeError: set_autocommit() got an unexpected keyword argument 'force_begin_transaction_with_broken_autocommit'
Ah ha! This is the error you get if you upgrade to Django 1.9 while using django-transaction-hooks and leave the transaction-hooks engine set up in settings.

Haystack UnicodeDecodeError

I'm using haystack and solr on Django. I get UnicodeDecodeError and I think the reason is the unicode data in the database are either converted to str or decoded to utf-8 which makes a later UnicodeDecodeError when sending via httplib or printing to the console.
I think the problem should before the haystack full_prepare function, since as I checked afterwards data is already ruined.
Any thoughts?
I setup.pyed install (haystack, pysolr, django)
and used the binary of lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Pouria\Desktop\conference\conference>python manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
Failed to clear Solr index: [Reason: Error 404 Not Found]
All documents removed.
C:\Python27\lib\site-packages\django\db\models\fields\__init__.py:808: RuntimeWarning: DateTimeField
received a naive datetime (2013-02-09 08:47:27.110000) while time zone support is active.
RuntimeWarning)
Indexing 2 conferences.
ERROR:root:Error updating conferences using default
Traceback (most recent call last):
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 210, in handle_label
self.update_backend(label, using)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 256, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 78, in do_update
backend.update(index, current_qs)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\backends\solr_backend.py", line 72, i
n update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "C:\Python27\lib\site-packages\pysolr.py", line 786, in add
return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
File "C:\Python27\lib\site-packages\pysolr.py", line 379, in _update
return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
File "C:\Python27\lib\site-packages\pysolr.py", line 291, in _send_request
timeout=self.timeout)
File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies
)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 373, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 171, in send
timeout=timeout
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 421, in url
open
body=body, headers=headers)
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 273, in _ma
ke_request
conn.request(method, url, **httplib_request_kw)
File "C:\Python27\lib\httplib.py", line 949, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 990, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 943, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 810, in _send_output
self.send(message_body)
File "C:\Python27\lib\httplib.py", line 775, in send
self.sock.sendall(str)
File "C:\Python27\lib\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143-149: ordinal not in range(
128)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from
_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\rebuild_index.py"
, line 15, in handle
call_command('update_index', **options)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 184, in handle
return super(Command, self).handle(*items, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 341, in handle
label_output = self.handle_label(label, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 210, in handle_label
self.update_backend(label, using)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 256, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 78, in do_update
backend.update(index, current_qs)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\backends\solr_backend.py", line 72, i
n update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "C:\Python27\lib\site-packages\pysolr.py", line 786, in add
return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
File "C:\Python27\lib\site-packages\pysolr.py", line 379, in _update
return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
File "C:\Python27\lib\site-packages\pysolr.py", line 291, in _send_request
timeout=self.timeout)
File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies
)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 373, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 171, in send
timeout=timeout
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 421, in url
open
body=body, headers=headers)
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 273, in _ma
ke_request
conn.request(method, url, **httplib_request_kw)
File "C:\Python27\lib\httplib.py", line 949, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 990, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 943, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 810, in _send_output
self.send(message_body)
File "C:\Python27\lib\httplib.py", line 775, in send
self.sock.sendall(str)
File "C:\Python27\lib\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143-149: ordinal not in range(
128)
I had the same error. It's seams to be fixed on master https://github.com/toastdriven/django-haystack. So you should use haystack 2.0 alpha/beta.

Django unit tests spews database error - cannot commit transaction - SQL statements in progress

I'm using unittest2 together with manage.py test, and before it even seems to run any tests, it spews a horrid database error, as below. I'm in my development environment (actually on a dreamhost server for a variety of reasons), using sqlite as my database.
Even when I copy my app out of where it is for production (and edit settings.py accordingly), I still get the same error (even though it should no longer be addressing the same database file as the dev environment).
Update: Even moving all instances of my database files to a different filename still leaves me with the same error. This leads me to believe that the test environment is somehow looking at a bogus database, or something very odd is happening.
[graffias]$ python manage.py test
Creating test database for alias 'default'...
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/test.py", line 8, in handle
super(Command, self).handle(*args, **kwargs)
File "/home/marcintustin/django/Django-1.3/django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
File "/home/marcintustin/django/Django-1.3/django/test/simple.py", line 359, in run_tests
old_config = self.setup_databases()
File "/home/marcintustin/django/Django-1.3/django/test/simple.py", line 296, in setup_databases
test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
File "/home/marcintustin/django/Django-1.3/django/db/backends/creation.py", line 366, in create_test_db
load_initial_data=False)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/syncdb.py", line 99, in handle_noargs
management.call_command('migrate', **options)
File "/home/marcintustin/django/Django-1.3/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/home/marcintustin/django/Django-1.3/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/__init__.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/migrators.py", line 221, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/migration/migrators.py", line 298, in migrate_many
interactive=self.interactive)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/db/generic.py", line 808, in send_pending_create_signals
interactive=interactive)
File "/home/marcintustin/django/South-0.7.3-py2.5.egg/south/db/generic.py", line 855, in really_send_create_signal
db=self.db_alias,
File "/home/marcintustin/django/Django-1.3/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/home/marcintustin/django/Django-1.3/django/contrib/auth/management/__init__.py", line 30, in create_permissions
ctype = ContentType.objects.get_for_model(klass)
File "/home/marcintustin/django/Django-1.3/django/contrib/contenttypes/models.py", line 38, in get_for_model
defaults = {'name': smart_unicode(opts.verbose_name_raw)},
File "/home/marcintustin/django/Django-1.3/django/db/models/manager.py", line 135, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "/home/marcintustin/django/Django-1.3/django/db/models/query.py", line 385, in get_or_create
obj.save(force_insert=True, using=self.db)
File "/home/marcintustin/django/Django-1.3/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/marcintustin/django/Django-1.3/django/db/models/base.py", line 560, in save_base
transaction.commit_unless_managed(using=using)
File "/home/marcintustin/django/Django-1.3/django/db/transaction.py", line 124, in commit_unless_managed
connection.commit_unless_managed()
File "/home/marcintustin/django/Django-1.3/django/db/backends/__init__.py", line 183, in commit_unless_managed
self._commit()
File "/home/marcintustin/django/Django-1.3/django/db/backends/__init__.py", line 46, in _commit
return self.connection.commit()
pysqlite2.dbapi2.OperationalError: cannot commit transaction - SQL statements in progress
Basically, I have no idea where to start with fixing this. Any ideas?