regebro / tzlocal

A Python module that tries to figure out what your local timezone is
MIT License
185 stars 58 forks source link

cannot import name 'get_localzone_name' from 'tzlocal' #159

Open microdinosaur opened 8 months ago

microdinosaur commented 8 months ago

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.

regebro commented 8 months ago

What's the full error message?

microdinosaur commented 8 months ago
---------------------------------------------------------------------------
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']

regebro commented 8 months ago

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

microdinosaur commented 8 months ago

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.

regebro commented 8 months ago

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.