jonchun / allcities

Python library to access all the cities of the world with a population of at least 1000 inhabitants.
MIT License
6 stars 5 forks source link

ImportError: cannot import name 'Set' from 'collections' #2

Open KnightChaser opened 1 month ago

KnightChaser commented 1 month ago

There seems to be a package import error in your code, making me unable to use your package.

I installed the package like below

pip install allcities

Encountered the exception below

PS C:\Users\3NR1QUE> python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from allcities import cities
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python312\Lib\site-packages\allcities\__init__.py", line 14, in <module>
    from .core import all_cities as cities
  File "C:\Python312\Lib\site-packages\allcities\core.py", line 18, in <module>
    from allcities.cityset import CitySet
  File "C:\Python312\Lib\site-packages\allcities\cityset.py", line 4, in <module>
    from collections import Set
ImportError: cannot import name 'Set' from 'collections' (C:\Python312\Lib\collections\__init__.py)
>>>
MisileLab commented 3 weeks ago

I think package fixed but doesn't published try this

pip install requests
pip install git+https://github.com/jonchun/allcities.git

(I don't know why requests doesn't install when install with git)

KnightChaser commented 3 weeks ago

It's still making some unable-to-fix errors. I guess the package management is misconfigured...

When I tried your suggestion on my Windows laptop(Windows 11, x64, Python v3.11.9), I get the following output for your suggestions:

PS C:\Users\user> pip install requests
Requirement already satisfied: requests in c:\users\user\.pyenv\pyenv-win\versions\3.11.9\lib\site-packages (2.32.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\user\.pyenv\pyenv-win\versions\3.11.9\lib\site-packages (from requests) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user\.pyenv\pyenv-win\versions\3.11.9\lib\site-packages (from requests) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\user\.pyenv\pyenv-win\versions\3.11.9\lib\site-packages (from requests) (2.2.2)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\.pyenv\pyenv-win\versions\3.11.9\lib\site-packages (from requests) (2024.7.4)

[notice] A new release of pip is available: 24.1.2 -> 24.2
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\user> pip install git+https://github.com/jonchun/allcities.git
Collecting git+https://github.com/jonchun/allcities.git
  Cloning https://github.com/jonchun/allcities.git to c:\users\user\appdata\local\temp\pip-req-build-bpr4_ke3
  Running command git clone --filter=blob:none --quiet https://github.com/jonchun/allcities.git 'C:\Users\user\AppData\Local\Temp\pip-req-build-bpr4_ke3'
  Resolved https://github.com/jonchun/allcities.git to commit e39443413e4895b0b27b79483d7c65b89abac387
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      Traceback (most recent call last):
        File "C:\Users\user\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\user\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\.pyenv\pyenv-win\versions\3.11.9\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8_9gi50l\overlay\Lib\site-packages\setuptools\build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8_9gi50l\overlay\Lib\site-packages\setuptools\build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8_9gi50l\overlay\Lib\site-packages\setuptools\build_meta.py", line 516, in run_setup
          super().run_setup(setup_script=setup_script)
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-8_9gi50l\overlay\Lib\site-packages\setuptools\build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 2, in <module>
        File "C:\Users\user\AppData\Local\Temp\pip-req-build-bpr4_ke3\allcities\__init__.py", line 14, in <module>
          from .core import all_cities as cities
        File "C:\Users\user\AppData\Local\Temp\pip-req-build-bpr4_ke3\allcities\core.py", line 14, in <module>
          import requests
      ModuleNotFoundError: No module named 'requests'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 24.1.2 -> 24.2
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\user>

(Even though I installed requests package, the second line of the commands still make the error that requests package is not found lol)