regebro / tzlocal

A Python module that tries to figure out what your local timezone is

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot import name 'get_localzone_name' from 'tzlocal'

microdinosaur opened this issue · comments

I'm unable to import or run the function get_localzone_name. I've tried uninstalling and reinstalling a few times and rolling back to previous versions. I'm in a conda env but I've also tried installing through pip and no luck.

Everything looks good in the files - but for whatever reason it's failing no matter how I load. M1 Pro if it helps.

What's the full error message?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[48], line 1
----> 1 from tzlocal import get_localzone_name

ImportError: cannot import name 'get_localzone_name' from 'tzlocal' (/Users/mrodin024/anaconda3/envs/ebi/lib/python3.11/site-packages/tzlocal/__init__.py)

When I run dir(tzlocal) to check, I get this return - no 'get_localzone_name' in the list.
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'get_localzone', 'reload_localzone', 'sys', 'unix', 'utils']

It looks like you are using version 3.0 (or earlier). get_localzone_name was added in 4.0b1.

Yeah - I was wondering if it was a version issue but I checked and I've got version 5.2 loaded according to my code.

Well, you can look at /Users/mrodin024/anaconda3/envs/ebi/lib/python3.11/site-packages/tzlocal/__init__.py and see how it looks. If it includes get_localzone_name and you still get this error I think probably your install has become messed up and needs recreating.