ipeaGIT / geobr

Easy access to official spatial data sets of Brazil in R and Python
https://ipeagit.github.io/geobr/
778 stars 116 forks source link

Problem with pip install #336

Closed ProfLeao closed 3 months ago

ProfLeao commented 6 months ago

When I try to install the package with pip in SO Windows, I get the followingoutput.

Can anyone help me?

(geo_env) PS C:\Users\profr> pip install geobr
Collecting geobr
  Using cached geobr-0.2.0-py2.py3-none-any.whl (34 kB)
Collecting geopandas<0.8.0,>=0.7.0 (from geobr)
  Using cached geopandas-0.7.0-py2.py3-none-any.whl (928 kB)
Collecting shapely<2.0.0,>=1.7.0 (from geobr)
  Using cached Shapely-1.8.5.post1.tar.gz (200 kB)
  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
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "C:\Users\profr\anaconda3\envs\geo_env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\profr\anaconda3\envs\geo_env\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\profr\anaconda3\envs\geo_env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "C:\Users\profr\anaconda3\envs\geo_env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\profr\anaconda3\envs\geo_env\Lib\importlib\__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 994, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "C:\Users\profr\AppData\Local\Temp\pip-build-env-c2699h3v\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
          import setuptools.version
        File "C:\Users\profr\AppData\Local\Temp\pip-build-env-c2699h3v\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
          import pkg_resources
        File "C:\Users\profr\AppData\Local\Temp\pip-build-env-c2699h3v\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [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.
rafapereirabr commented 6 months ago

@BAFurtado , could you please have a quick look at this?

BAFurtado commented 6 months ago

There's probably a version incompatibility. I would try a new env from scratch including at once all necessary packages.

Something like:

conda create -n my_new_env geobr ... geoandas... shapely ... whatever Do not state specific version numbers and let conda decide on the latest possible.

Or the equivalent in pip.

Specifically, shapely, gdal and geopandas are tricky to install. So the best way is to do it together using conda Other pythonists nowadays use poetryand other env managers. Conda has worked fine for me.

erickfaria commented 6 months ago

The error you're encountering seems to be related to a compatibility or dependency issue. I just installed geobr without any problem. You might want to try creating a new environment to test it. This approach often resolves conflicts and issues related to specific package installations.

ProfLeao commented 6 months ago

I tried it a few times, but the problem still persists in Win11.

Lucas-Pavesys commented 4 months ago

This seems to be an issue in your pip version. Due to the removal of the long-deprecated pkgutil.ImpImporter class, the pip command may not work for Python 3.12 or newer versions.

To fix this issue you can follow this steps:

  1. Download the package https://pypi.org/project/geobr/#files;
  2. Unzip it;
  3. cd into the package directory;
  4. type python setup.py install for windows or sudo python setup.py install for ubuntu; note: you may need administrator privileges for the 4th step

Please try this solution and tell me how it goes : )

JoaoCarabetta commented 4 months ago

I just updated the package dependencies (PR #341).

All issues related to dependencies and installation should be solved with it.

Try pip install geobr -U to try the new version and let me know how it goes.