简体   繁体   中英

Installing geopandas with anaconda prompt causes ImportError

I am aiming to analyse geodata in python but fail on step 1: the installation. I'm relatively new to python and used to installing packages with pip. Now, for geopandas, it looks like I'm supposed to use conda install. Sadly, I get an error.

What I did: I downloaded the most recent anconda software and typed 'conda install geopandas' in the anaconda prompt (anaconda3).

Reading similar questions online I saw some questions solved by updating anaconda, but since I downloaded the version on the homepage I would expect it to be up to date. Also, I didn't find any entries with error code similar to mine.

From what I gather from the response, anaconda didn't even manage to find the package (first line of the below code). However, I am not very experienced in the analysis of error code.

Any help would be greatly appreciated!

The error-code

Collecting package metadata (current_repodata.json): failed
WARNING conda.exceptions:print_unexpected_error_report(1213): KeyError('pkgs_dirs')
Traceback (most recent call last):
  File "D:\Programs\Anaconda3\lib\site-packages\conda\exceptions.py", line 1079, in __call__
    return func(*args, **kwargs)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
    exit_code = do_call(args, p)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 83, in do_call
    return getattr(module, func_name)(args, parser)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
    install(args, parser, 'install')
  File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\install.py", line 261, in install
    unlink_link_transaction = solver.solve_for_transaction(
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 114, in solve_for_transaction
    unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 157, in solve_for_diff
    final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 262, in solve_final_state
    ssc = self._collect_all_metadata(ssc)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
    return f(*args, **kwds)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 425, in _collect_all_metadata
    index, r = self._prepare(prepared_specs)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 1020, in _prepare
    reduced_index = get_reduced_index(self.prefix, self.channels,
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\index.py", line 276, in get_reduced_index
    new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 98, in query_all
    create_cache_dir()
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 674, in create_cache_dir
    cache_dir = join(PackageCacheData.first_writable().pkgs_dir, 'cache')
  File "D:\Programs\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 152, in first_writable
    pkgs_dirs = context.pkgs_dirs
  File "D:\Programs\Anaconda3\lib\site-packages\conda\base\context.py", line 520, in pkgs_dirs
    fixed_dirs += user_data_dir(APP_NAME, APP_NAME),
  File "D:\Programs\Anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 67, in user_data_dir
    path = os.path.join(_get_win_folder(const), appauthor, appname)
  File "D:\Programs\Anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 284, in _get_win_folder_with_pywin32
    from win32com.shell import shellcon, shell
ImportError: DLL load failed while importing shell: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Programs\Anaconda3\lib\site-packages\conda\exceptions.py", line 1211, in print_unexpected_error_report
    message_builder.append(get_main_info_str(error_report['conda_info']))
  File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 238, in get_main_info_str
    info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
KeyError: 'pkgs_dirs'

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "D:\Programs\Anaconda3\lib\site-packages\conda\exceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 83, in do_call
        return getattr(module, func_name)(args, parser)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 20, in execute
        install(args, parser, 'install')
      File "D:\Programs\Anaconda3\lib\site-packages\conda\cli\install.py", line 261, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 114, in solve_for_transaction
        unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 157, in solve_for_diff
        final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 262, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\common\io.py", line 88, in decorated
        return f(*args, **kwds)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 425, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\solve.py", line 1020, in _prepare
        reduced_index = get_reduced_index(self.prefix, self.channels,
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\index.py", line 276, in get_reduced_index
        new_records = SubdirData.query_all(spec, channels=channels, subdirs=subdirs,
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 98, in query_all
        create_cache_dir()
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\subdir_data.py", line 674, in create_cache_dir
        cache_dir = join(PackageCacheData.first_writable().pkgs_dir, 'cache')
      File "D:\Programs\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 152, in first_writable
        pkgs_dirs = context.pkgs_dirs
      File "D:\Programs\Anaconda3\lib\site-packages\conda\base\context.py", line 520, in pkgs_dirs
        fixed_dirs += user_data_dir(APP_NAME, APP_NAME),
      File "D:\Programs\Anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 67, in user_data_dir
        path = os.path.join(_get_win_folder(const), appauthor, appname)
      File "D:\Programs\Anaconda3\lib\site-packages\conda\_vendor\appdirs.py", line 284, in _get_win_folder_with_pywin32
        from win32com.shell import shellcon, shell
    ImportError: DLL load failed while importing shell: The specified module could not be found.

`$ D:\Programs\Anaconda3\Scripts\conda-script.py install geopandas`

  environment variables:
conda info could not be constructed.
KeyError('pkgs_dirs')

An unexpected error has occurred. Conda has prepared the above report.

I had the same issue back then, and I followed the instructions on this link.

https://medium.com/analytics-vidhya/fastest-way-to-install-geopandas-in-jupyter-notebook-on-windows-8f734e11fa2b

Basically what this does is create a new environment in your anaconda navigator where I could get geopandas working normally.

Bit late to the party, but here's an answer that worked for me, after more trouble than I want to get into.

Create conda environment

https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084

Install Dependencies (Preparing for Battle)

GeoPandas depends on the following Python libraries: pandas, Shapely, Fiona, pyproj, NumPy, six, descartes, and cartopy .

Go to https://anaconda.org/conda-forge/ and search each Dependency. Click on the first name of the first row (Example: pandas - in green next to 1.3.1, below) 在此处输入图像描述

On the page that takes you to, scroll down and copy and paste the highlighted line of code. 在此处输入图像描述

Paste that into your Terminal in your brand new environment and hit Enter.

Once all of the Dependencies have been successfully added to your new conda environment, copy the Geopandas line of code from the conda forge page just as you did for the Dependencies. Paste in your terminal and hit Enter. If the Gods of not-suck are with you, it will install.

Let me know when this works and if you need some good resources for how to use Geopandas

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM