Skip to content

TypeError: Only timezones from the pytz library are supported #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dishu1 opened this issue Oct 6, 2024 · 2 comments
Open

TypeError: Only timezones from the pytz library are supported #149

dishu1 opened this issue Oct 6, 2024 · 2 comments

Comments

@dishu1
Copy link

dishu1 commented Oct 6, 2024

Hi, I'm running the code below in a conda environment with python 3.11. I installed the library by doing git clone https://github.com/HuobiRDCenter/huobi_Python.git, cd into directory, pip install -r requirements.txt and pip install .

`from huobi.client.market import MarketClient
from huobi.model.market import *

def callback(obj_event: 'MarketDetailEvent'):
obj_event.print_object()
print()

market_client = MarketClient()
market_client.sub_market_detail("btcusdt", callback)`

And I get:
Traceback (most recent call last):
File "htx.py", line 11, in
market_client.sub_market_detail("btcusdt", callback)
File "miniconda3/envs/htx/lib/python3.11/site-packages/huobi/client/market.py", line 273, in sub_market_detail
from huobi.service.market.sub_market_detail import SubMarketDetailService
File "miniconda3/envs/htx/lib/python3.11/site-packages/huobi/service/market/sub_market_detail.py", line 5, in
from huobi.connection.subscribe_client import SubscribeClient
File "miniconda3/envs/htx/lib/python3.11/site-packages/huobi/connection/subscribe_client.py", line 9, in
class SubscribeClient(object):
File "miniconda3/envs/htx/lib/python3.11/site-packages/huobi/connection/subscribe_client.py", line 11, in SubscribeClient
subscribe_watch_dog = WebSocketWatchDog()
^^^^^^^^^^^^^^^^^^^
File "miniconda3/envs/htx/lib/python3.11/site-packages/huobi/connection/impl/websocket_watchdog.py", line 42, in init
self.scheduler.add_job(watch_dog_job, "interval", max_instances=10, seconds=1, args=[self])
File "miniconda3/envs/htx/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 420, in add_job
'trigger': self._create_trigger(trigger, trigger_args),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "miniconda3/envs/htx/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 921, in _create_trigger
return self._create_plugin_instance('trigger', trigger, trigger_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "miniconda3/envs/htx/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 906, in _create_plugin_instance
return plugin_cls(**constructor_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "miniconda3/envs/htx/lib/python3.11/site-packages/apscheduler/triggers/interval.py", line 38, in init
self.timezone = astimezone(timezone)
^^^^^^^^^^^^^^^^^^^^
File "miniconda3/envs/htx/lib/python3.11/site-packages/apscheduler/util.py", line 93, in astimezone
raise TypeError('Only timezones from the pytz library are supported')
TypeError: Only timezones from the pytz library are supported

I can't even guess because no examples seem to use the timezone in any way.

@YusenFan
Copy link

YusenFan commented Jan 30, 2025

I've encountered the same issue, did you manage to solve it?

@YusenFan
Copy link

This issue is because of imcompatible of python veriosn changes.
If you using python 3.11 , it will rasie some internal timezone handing. this issue occurs when apscheduler is installed with versions that are not fully compatible with Python 3.11.

Resolve this issue by add below

From:
self.scheduler = BlockingScheduler()
To:
self.scheduler = BlockingScheduler(timezone=pytz.timezone("UTC"))

in huobi/connection/impl/websocket_watchdog.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants