OpenBB-finance / OpenBB

Investment Research for Everyone, Everywhere.
https://openbb.co
Other
33.54k stars 3.06k forks source link

Timezone offset does not match system offset: 0 != 3600 #1695

Closed rochdikhalid closed 2 years ago

rochdikhalid commented 2 years ago

I forked the OpenBBTerminal repository and I followed the instructions to install the project on my Ubuntu machine to explore the source code repository (Developer Approach) but when I want to run and use the terminal by this command python terminal.py, the following bug has occurred:

ValueError: Timezone offset does not match system offset: 0 != 3600. Please, check your config files.

I did a little research and I found that the library is looking up the timezone configuration. My timezone is UTC and it seems like other parts of the system disagree.

For more details, here is the full traceback concerning this bug:

Traceback (most recent call last):
  File "terminal.py", line 30, in <module>
    from openbb_terminal.parent_classes import BaseController
  File "/home/rochdikhalid/openBB/OpenBBTerminal/openbb_terminal/parent_classes.py", line 33, in <module>
    from openbb_terminal.stocks import stocks_helper
  File "/home/rochdikhalid/openBB/OpenBBTerminal/openbb_terminal/stocks/stocks_helper.py", line 18, in <module>
    import pyEX
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/pyEX/__init__.py", line 8, in <module>
    from .client import *  # noqa: F403
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/pyEX/client.py", line 14, in <module>
    from .alternative import ceoCompensation, ceoCompensationDF, sentiment, sentimentDF
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/pyEX/alternative/__init__.py", line 8, in <module>
    from .alternative import ceoCompensation, ceoCompensationDF, sentiment, sentimentDF
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/pyEX/alternative/alternative.py", line 78, in <module>
    def ceoCompensation(symbol, token="", version="stable", filter="", format="json"):
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/pyEX/common/timing.py", line 28, in _wrapper
    return expire(**temporal_args)(foo)
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/temporalcache/expire.py", line 69, in expire
    tz = tz or get_localzone()
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/tzlocal/unix.py", line 203, in get_localzone
    _cache_tz = _get_localzone()
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/tzlocal/unix.py", line 185, in _get_localzone
    utils.assert_tz_offset(tz)
  File "/home/rochdikhalid/anaconda3/envs/gst/lib/python3.8/site-packages/tzlocal/utils.py", line 63, in assert_tz_offset
    raise ValueError(msg)
ValueError: Timezone offset does not match system offset: 0 != 3600. Please, check your config files.

Desktop:

rochdikhalid commented 2 years ago

I could fix the bug using tzselect and .profile. Here are some instructions you can follow to fix this timezone bug:

  1. Run the tzselect command.
  2. Select your geographic area by number (eg. Africa: 1).
    Please identify a location so that time zone rules can be set correctly.
    Please select a continent, ocean, "coord", or "TZ".
    1) Africa                                7) Europe
    2) Americas                              8) Indian Ocean
    3) Antarctica                                9) Pacific Ocean
    4) Asia                                 10) coord - I want to use geographical coordinates.
    5) Atlantic Ocean                           11) TZ - I want to specify the timezone using the Posix TZ format.
    6) Australia
    #? 1
  3. Select your country or a country whose clocks agree with yours (eg. Morocco: 34):
    Please select a country whose clocks agree with yours.
    1) Algeria       12) Congo (Rep.)      23) Guinea            34) Morocco       45) South Sudan
    2) Angola        13) Côte d'Ivoire     24) Guinea-Bissau         35) Mozambique        46) Spain
    3) Benin         14) Djibouti          25) Kenya             36) Namibia       47) St Helena
    4) Botswana          15) Egypt         26) Lesotho           37) Niger         48) Sudan
    5) Burkina Faso      16) Equatorial Guinea     27) Liberia           38) Nigeria       49) Tanzania
    6) Burundi       17) Eritrea           28) Libya             39) Rwanda        50) Togo
    7) Cameroon          18) Eswatini (Swaziland)  29) Madagascar        40) Sao Tome & Principe   51) Tunisia
    8) Central African Rep.  19) Ethiopia          30) Malawi            41) Senegal       52) Uganda
    9) Chad          20) Gabon         31) Mali              42) Sierra Leone      53) Western Sahara
    10) Comoros       21) Gambia            32) Mauritania        43) Somalia       54) Zambia
    11) Congo (Dem. Rep.)     22) Ghana         33) Mayotte           44) South Africa      55) Zimbabwe
    #? 34
  4. Select Yes if the given information is OK (eg. Yes: 1)

    
    The following information has been given:
    
    Morocco

Therefore TZ='Africa/Casablanca' will be used. Selected time is now: Mon 18 Apr 2022 08:44:37 AM +00. Universal Time is now: Mon 18 Apr 2022 08:44:37 AM UTC. Is the above information OK? 1) Yes 2) No

? 1

5. Make the change permanent and append it to `.profile` as follows:

You can make this change permanent for yourself by appending the line TZ='Africa/Casablanca'; export TZ to the file '.profile' in your home directory; then log out and log in again.

Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: Africa/Casablanca

6. Go to the Home directory and run `.profile` to append your changes. Here is an example of how to append your changes to your `.profile`:

TZ='Africa/Casablanca' export TZ


7. Next, log out and log in again to confirm your changes.
8. Then, activate the `gst` environment and go to the directory **OpenBBTerminal**.
9. Now, you can run the terminal using `python terminal.py` and have fun.

Also, you can read this [thread](https://github.com/regebro/tzlocal/issues/79) for more details on how to fix the same bug.