lschmelzeisen / nasty

NASTY Advanced Search Tweet Yielder
Apache License 2.0
49 stars 9 forks source link

ImportError: cannot import name 'Counter' (from typing) #5

Closed ziyad121 closed 4 years ago

ziyad121 commented 4 years ago

Problem in importing Counter. How can I fix it?

$ nasty search --query "climate"

Traceback (most recent call last):
  File "c:\users\meftahzd\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\meftahzd\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\meftahzd\AppData\Local\Programs\Python\Python36\Scripts\nasty.exe\__main__.py", line 5, in <module>
  File "c:\users\meftahzd\appdata\local\programs\python\python36\lib\site-packages\nasty\__init__.py", line 19, in <module>
    from .batch.batch import Batch
  File "c:\users\meftahzd\appdata\local\programs\python\python36\lib\site-packages\nasty\batch\batch.py", line 37, in <module>
    from .batch_results import BatchResults
  File "c:\users\meftahzd\appdata\local\programs\python\python36\lib\site-packages\nasty\batch\batch_results.py", line 20, in <module>
    from typing import (

ImportError: cannot import name 'Counter'
lschmelzeisen commented 4 years ago

The problem seems to be with importing typing.Counter. Can you run a new Python script just with the following?

from typing import Counter

Also, what Python version are you running?

For me I get Python 3.6.9 (default, Nov 23 2019, 06:41:34) and sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0), respectively. With that importing typing.Counter should not be a problem.

ziyad121 commented 4 years ago

I also get the same thing you got for sys version : sys.version_info(major=3,minor=6, micro=0, releaselevel='final', serial=0) and $ python -VV

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)]

The script for typing.Counter runs just fine.

lschmelzeisen commented 4 years ago

Hm, according to the documentation typing.Counter should only be available starting from Python 3.6.1.

Could you try upgrading your Python installation to at least that?

Still, I am somewhat surprised that the plain from typing import Counter works for you because when starting with a plain Python 3.6.0 installation it fails for me, e.g.:

$ docker run --rm -it python:3.6.0 python -c "from typing import Counter"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'Counter
ziyad121 commented 4 years ago

The upgrade to a higher version did the job.

Thank you