KeyError when deploying through Github to Heroku - python

I have pushed my repository through github. Myrepository can be found here: https://github.com/cody8522/fmv_app
I am receiving an error when deploying my app:
2022-05-27 14:10:40.585 Uncaught app exception
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 126, in get_or_create_cached_value
return_value = cache.read_value(value_key)
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 408, in read_value
raise e
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 401, in read_value
pickled_value = self._read_from_mem_cache(key)
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/memo_decorator.py", line 444, in _read_from_mem_cache
raise CacheKeyNotFoundError("Key not found in mem cache")
streamlit.caching.cache_errors.CacheKeyNotFoundError: Key not found in mem cache
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 443, in _run_script
exec(code, module.__dict__)
File "/app/fmv_app/web_app.py", line 39, in <module>
csv_load()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 145, in wrapper
return get_or_create_cached_value()
File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/caching/cache_utils.py", line 135, in get_or_create_cached_value
return_value = func(*args, **kwargs)
File "/app/fmv_app/web_app.py", line 25, in csv_load
df = df.merge(pd.read_csv('Venue Information.csv').rename(columns={'Venue':'Name'})[['Name','Adjusted Capacity']],on='Name').drop('Unnamed: 0',axis=1)
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 7284, in merge
return merge(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 73, in merge
op = _MergeOperation(
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 627, in __init__
) = self._get_merge_keys()
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/reshape/merge.py", line 996, in _get_merge_keys
left_keys.append(left._get_label_or_level_values(lk))
File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 1692, in _get_label_or_level_values
raise KeyError(key)
KeyError: 'Name'
It seems like the KeyError is coming from line 25 of my code:
df = df.merge(pd.read_csv('Venue Information.csv').rename(columns={'Venue':'Name'})[['Name','Adjusted Capacity']],on='Name').drop('Unnamed: 0',axis=1)
The code works fine locally but I am just having this issue when trying to deploy the application. Please let us know if there are any suggestions of what might be causing this. Thank you!

Related

ray.tune.error.TuneError: The Ray Tune run failed

This is from the ray package official code, it works well on Linux systems but appears some errors on windows. All of the ray version is 2.2.0.
import numpy as np
import ray
from ray import air, tune
from ray.air import session
from ray.air.integrations.wandb import setup_wandb
from ray.air.integrations.wandb import WandbLoggerCallback
def train_function(config):
for i in range(30):
loss = config["mean"] + config["sd"] * np.random.randn()
session.report({"loss": loss})
def tune_with_callback():
"""Example for using a WandbLoggerCallback with the function API"""
tuner = tune.Tuner(
train_function,
tune_config=tune.TuneConfig(
metric="loss",
mode="min"
),
run_config=air.RunConfig(
callbacks=[
WandbLoggerCallback(project="Wandb_example")
]
),
param_space={
"mean": tune.grid_search([1, 2, 3, 4, 5]),
"sd": tune.uniform(0.2, 0.8),
},
)
tuner.fit()
if __name__ == '__main__':
tune_with_callback()
And this is printed log with running above python code:
2022-12-30 11:50:41,732 INFO worker.py:1538 -- Started a local Ray instance.
2022-12-30 11:50:46,508 INFO wandb.py:250 -- Already logged into W&B.
Traceback (most recent call last):
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 928, in _wait_and_handle_event
self._on_pg_ready(next_trial)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 1018, in _on_pg_ready
if not _start_trial(next_trial) and next_trial.status != Trial.ERROR:
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 1010, in _start_trial
self._callbacks.on_trial_start(
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\callback.py", line 317, in on_trial_start
callback.on_trial_start(**info)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\logger\logger.py", line 135, in on_trial_start
self.log_trial_start(trial)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\air\integrations\wandb.py", line 527, in log_trial_start
self._trial_processes[trial].start()
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\air\integrations\wandb.py", line 367, in __reduce__
raise RuntimeError("_WandbLoggingProcess is not pickleable.")
RuntimeError: _WandbLoggingProcess is not pickleable.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\tuner.py", line 272, in fit
return self._local_tuner.fit()
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\impl\tuner_internal.py", line 420, in fit
analysis = self._fit_internal(trainable, param_space)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\impl\tuner_internal.py", line 532, in _fit_internal
analysis = run(
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\tune.py", line
726, in run
runner.step()
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 981, in step
self._wait_and_handle_event(next_trial)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 960, in _wait_and_handle_event
raise TuneError(traceback.format_exc())
ray.tune.error.TuneError: Traceback (most recent call last):
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 928, in _wait_and_handle_event
self._on_pg_ready(next_trial)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 1018, in _on_pg_ready
if not _start_trial(next_trial) and next_trial.status != Trial.ERROR:
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\execution\trial_runner.py", line 1010, in _start_trial
self._callbacks.on_trial_start(
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\callback.py", line 317, in on_trial_start
callback.on_trial_start(**info)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\logger\logger.py", line 135, in on_trial_start
self.log_trial_start(trial)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\air\integrations\wandb.py", line 527, in log_trial_start
self._trial_processes[trial].start()
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
reduction.dump(process_obj, to_child)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\air\integrations\wandb.py", line 367, in __reduce__
raise RuntimeError("_WandbLoggingProcess is not pickleable.")
RuntimeError: _WandbLoggingProcess is not pickleable.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\shaohan.tian\Desktop\laptop_python_run\wandb_test.py", line 36, in <module>
tune_with_callback()
File "C:\Users\shaohan.tian\Desktop\laptop_python_run\wandb_test.py", line 33, in tune_with_callback
tuner.fit()
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\site-packages\ray\tune\tuner.py", line 274, in fit
raise TuneError(
ray.tune.error.TuneError: The Ray Tune run failed. Please inspect the previous error messages for a cause. After
fixing the issue, you can restart the run from scratch or continue this run. To continue this run, you can use `tuner = Tuner.restore("C:\Users\shaohan.tian\ray_results\train_function_2022-12-30_11-50-36")`.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\shaohan.tian\scoop\apps\miniconda3\current\envs\steel\lib\multiprocessing\spawn.py", line 126, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
I tried modifying versions of ray and wandb, but it was of no use. Could you help me to solve it?

Why does python p5 give so much errors and warnings?

I'm trying to use the Python Processing port by Abhik Pal and Manindra Mohrarna. It seems to work fine, but it gives lots of warnings and errors and it really bothers me.
WARNING: Traceback (most recent call last):
File "C:\Users\gabri\Documents\Programmazione\Python\p5Sketchbook\test.py", line 10, in <module>
run()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\userspace.py", line 155, in run
p5.sketch = Sketch(setup_method, draw_method, handlers, frame_rate)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\base.py", line 60, in __init__
app.Canvas.__init__(
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\canvas.py", line 211, in __init__
self.create_native()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\canvas.py", line 228, in create_native
self._app.backend_module.CanvasBackend(self, **self._backend_kwargs)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\backends\_glfw.py", line 298, in __init__
self._on_resize(self._id, size[0], size[1])
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\backends\_glfw.py", line 394, in _on_resize
self._vispy_canvas.events.resize(
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 453, in __call__
self._invoke_callback(cb, event)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
_handle_exception(self.ignore_callback_errors,
<< caught exception here: >>
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 469, in _invoke_callback
cb(event)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\base.py", line 157, in on_resize
p5.renderer.reset_view()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\renderer2d.py", line 82, in reset_view
self.texture_prog['modelview'] = self.modelview_matrix.T.flatten()
TypeError: 'NoneType' object does not support item assignment
ERROR: Invoking <bound method Sketch.on_resize of <Sketch (Glfw) at 0x1fba232bfd0>> for ResizeEvent
Exception ignored on calling ctypes callback function: <function CanvasBackend._on_close at 0x000001FBA2375EA0>
Traceback (most recent call last):
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\glfw\__init__.py", line 660, in callback_wrapper
return func(*args, **kwargs)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\backends\_glfw.py", line 400, in _on_close
self._vispy_canvas.close()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\app\canvas.py", line 463, in close
self.events.close()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 453, in __call__
self._invoke_callback(cb, event)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\vispy\util\event.py", line 469, in _invoke_callback
cb(event)
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\base.py", line 148, in on_close
exit()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\_sitebuiltins.py", line 26, in __call__
raise SystemExit(code)
SystemExit: None
Traceback (most recent call last):
File "C:\Users\gabri\Documents\Programmazione\Python\p5Sketchbook\test.py", line 10, in <module>
run()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\userspace.py", line 167, in run
exit()
File "C:\Users\gabri\AppData\Local\Programs\Python\Python310\lib\site-packages\p5\sketch\userspace.py", line 250, in exit
p5.exit(*args, **kwargs)
AttributeError: module 'p5.core.p5' has no attribute 'exit'
Process returned 1 (0x1) execution time : 20.330 s
What does this mean? Why does it happen and is there a way to fix this?

AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'

I've been upgrading our Django/Python app to Python 3.9.7 and Django 3.2.7 (from Python 3.5 and Django 1.11.23).
Currently if I try to run python manage.py createsuperuser
I get the following error
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
key = self._selector.get_key(fd)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 193, in get_key
raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '10 is not registered'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/Development/app/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/core/management/base.py", line 367, in run_from_argv
connections.close_all()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/db/utils.py", line 213, in close_all
connection.close()
File "/Users/myuser/.pyenv/versions/insta9/lib/python3.9/site-packages/django/utils/asyncio.py", line 19, in inner
event_loop = asyncio.get_event_loop()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 639, in get_event_loop
self.set_event_loop(self.new_event_loop())
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
return self._loop_factory()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
super().__init__(selector)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
self._make_self_pipe()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
self._add_reader(self._ssock.fileno(), self._read_from_self)
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
self._selector.register(fd, selectors.EVENT_READ,
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/selectors.py", line 523, in register
self._selector.control([kev], 0, 0)
TypeError: changelist must be an iterable of select.kevent objects
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
Exception ignored in: <function BaseEventLoop.__del__ at 0x103307310>
Traceback (most recent call last):
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/base_events.py", line 683, in __del__
self.close()
File "/Users/myuser/.pyenv/versions/3.9.7/lib/python3.9/asyncio/unix_events.py", line 63, in close
if self._signal_handlers:
AttributeError: '_UnixSelectorEventLoop' object has no attribute '_signal_handlers'
These are some of the versions I'm using in my requirements.txt
Django==3.2.7
django-braces==1.14.0
django-pipeline==2.0.6
django-storages==1.11.1
djangorestframework==3.12.4
django-localflavor==2.0
django-redis==5.0.0
django_guardian==2.4.0
django-debug-toolbar==3.2.2
django-grappelli==2.15.1
django-extensions==3.1.3
django-simple-history==3.0.0
django-cities-light==3.8.1
django-autoslug==1.9.8
django-constance==2.8.0
django-jsonify==0.3.0
django-bulk-update==2.2.0
django-sslserver==0.22
django-admin-easy==0.6.1
django-admin-rangefilter==0.8.1
django-model-utils==4.1.1
gunicorn==19.7.1
honcho==0.7.1
ipython==5.6.0
eventlet==0.32.0
selenium==2.53.2
This also seems to happen when I runserver, and then kill the server again. Any ideas what could be causing the issue?
Sometimes you don't need async functionality to run the application. In that case set allow async unsafe.
export DJANGO_ALLOW_ASYNC_UNSAFE=True

NoReverseMatch: 'app_name' is not a registered namespace [django-watson]

Django : 1.11
Python : 3.5.x
DB : SQLite
Hi there
I'm pretty sure I already following the instruction, but still no luck. When I run ./manage.py buildwatson it's error :
# ./manage.py buildwatson
Traceback (most recent call last):
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/urls/base.py", line 77, in reverse
extra, resolver = resolver.namespace_dict[ns]
KeyError: 'app_trip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/python3.5/contextlib.py", line 30, in inner
return func(*args, **kwds)
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/management/commands/buildwatson.py", line 142, in handle
refreshed_model_count += rebuild_index_for_model(model, engine_slug, verbosity)
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/management/commands/buildwatson.py", line 61, in rebuild_index_for_model
_bulk_save_search_entries(iter_search_entries())
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/search.py", line 205, in _bulk_save_search_entries
search_entry_batch = list(islice(search_entries, 0, batch_size))
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/management/commands/buildwatson.py", line 40, in iter_search_entries
for search_entry in search_engine_._update_obj_index_iter(obj):
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/search.py", line 484, in _update_obj_index_iter
"url": adapter.get_url(obj),
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/watson/search.py", line 153, in get_url
return obj.get_absolute_url()
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/db/models/__init__.py", line 58, in inner
return reverse(bits[0], None, *bits[1:3])
File "/home/zea/Riset/Python/env_vakansea/lib/python3.5/site-packages/django/urls/base.py", line 87, in reverse
raise NoReverseMatch("%s is not a registered namespace" % key)
django.urls.exceptions.NoReverseMatch: 'app_trip' is not a registered namespace
I have an app called app_trip and models called Trip, and here is my codes:
# apps.py
from django.apps import AppConfig
from watson import search as watson
class AppTripConfig(AppConfig):
name = 'app_trip'
def ready(self):
Trip = self.get_model('Trip')
watson.register(Trip)
# __init__.py
default_app_config = 'app_trip.apps.AppTripConfig'
I'm stuck. I opened an issue on their github, but still no response. Any help would be greatly appreciated!
Thank you

Why does Tweepy with Python 3 not return any data at all from a stream?

Python 3.5.2, Tweepy 3.5.0, Windows 8.1
I'm following a tutorial made by sentdex that shows how to stream data from Twitter using tweepy. (His tutorial is in Python 2 but it is pretty easy to Python 3-ify it)
However, when I run the script, it doesn't spit out any data. It hangs until I get a 3-way IncompleteRead exception, or until I do Ctrl+C.
Here is my Listener class code:
class listener(StreamListener):
def on_date(self,data):
try:
print(data)
save = open('twitDB.csv', 'a')
save.write(data)
save.write('\n')
save.close()
return True
except BaseException as e:
print('failed on data,',str(e))
time.sleep(5)
def on_error(self,status):
print(status)
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken,asecret)
twitterStream = Stream(auth=auth, listener=listener())
twitterStream.filter(track=["car"])
As you can see, I have it set up to catch errors and print data out while saving it to a csv, but it doesn't really do anything, just hangs.
Also, for track, I did try to use something less general but it still hanged.
When KeyboardInterrupt is raised:
Traceback (most recent call last):
File "C:\Program Files\Python35\lib\site-packages\requests\packages\urllib3\co
ntrib\pyopenssl.py", line 217, in recv_into
return self.connection.recv_into(*args, **kwargs)
File "C:\Program Files\Python35\lib\site-packages\OpenSSL\SSL.py", line 1352,
in recv_into
self._raise_ssl_error(self._ssl, result)
File "C:\Program Files\Python35\lib\site-packages\OpenSSL\SSL.py", line 1167,
in _raise_ssl_error
raise WantReadError()
OpenSSL.SSL.WantReadError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "twittertest.py", line 33, in <module>
twitterStream.filter(track=["car"])
File "C:\Program Files\Python35\lib\site-packages\tweepy\streaming.py", line 4
45, in filter
self._start(async)
File "C:\Program Files\Python35\lib\site-packages\tweepy\streaming.py", line 3
61, in _start
self._run()
File "C:\Program Files\Python35\lib\site-packages\tweepy\streaming.py", line 2
63, in _run
self._read_loop(resp)
File "C:\Program Files\Python35\lib\site-packages\tweepy\streaming.py", line 3
13, in _read_loop
line = buf.read_line().strip()
File "C:\Program Files\Python35\lib\site-packages\tweepy\streaming.py", line 1
79, in read_line
self._buffer += self._stream.read(self._chunk_size)
File "C:\Program Files\Python35\lib\site-packages\requests\packages\urllib3\re
sponse.py", line 310, in read
data = self._fp.read(amt)
File "C:\Program Files\Python35\lib\http\client.py", line 448, in read
n = self.readinto(b)
File "C:\Program Files\Python35\lib\http\client.py", line 478, in readinto
return self._readinto_chunked(b)
File "C:\Program Files\Python35\lib\http\client.py", line 573, in _readinto_ch
unked
chunk_left = self._get_chunk_left()
File "C:\Program Files\Python35\lib\http\client.py", line 541, in _get_chunk_l
eft
chunk_left = self._read_next_chunk_size()
File "C:\Program Files\Python35\lib\http\client.py", line 501, in _read_next_c
hunk_size
line = self.fp.readline(_MAXLINE + 1)
File "C:\Program Files\Python35\lib\socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\Python35\lib\site-packages\requests\packages\urllib3\co
ntrib\pyopenssl.py", line 230, in recv_into
[self.socket], [], [], self.socket.gettimeout())
KeyboardInterrupt
It's my first time going with a social media API, so I apologize if I'm missing something obvious. Help would be appreciated, thanks.
def on_date(self,data):
This should have been
def on_data(self,data):
Never mind, when I use on_status with status.text, it works, must be something I'm missing.

Categories