简体   繁体   English

使用 anaconda 提示安装 geopandas 会导致 ImportError

[英]Installing geopandas with anaconda prompt causes ImportError

I am aiming to analyse geodata in python but fail on step 1: the installation.我的目标是分析 python 中的地理数据,但在第 1 步失败:安装。 I'm relatively new to python and used to installing packages with pip.我对 python 比较陌生,并且习惯于使用 pip 安装软件包。 Now, for geopandas, it looks like I'm supposed to use conda install.现在,对于 geopandas,看起来我应该使用 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).我做了什么:我下载了最新的 anconda 软件并在 anaconda 提示符 (anaconda3) 中输入了“conda install geopandas”。

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.在线阅读类似的问题,我看到通过更新 anaconda 解决了一些问题,但是由于我在主页上下载了版本,因此我希望它是最新的。 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).根据我从响应中收集到的信息,anaconda 甚至没有找到 package(以下代码的第一行)。 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 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.基本上,这样做是在您的 anaconda 导航器中创建一个新环境,我可以让 geopandas 正常工作。

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 创建 conda 环境

https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084 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 . GeoPandas 依赖于以下 Python 库: pandas、Shapely、Fiona、pyproj、NumPy、六个和笛卡尔

Go to https://anaconda.org/conda-forge/ and search each Dependency. Go 到https://anaconda.org/conda-forge/并搜索每个依赖项。 Click on the first name of the first row (Example: pandas - in green next to 1.3.1, below)单击第一行的名字(例如: pandas - 1.3.1 旁边的绿色,如下) 在此处输入图像描述

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.将其粘贴到您全新环境中的终端中,然后按 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.将所有依赖项成功添加到新的 conda 环境后,从 conda forge 页面复制 Geopandas 代码行,就像对依赖项所做的那样。 Paste in your terminal and hit Enter.粘贴到您的终端并按 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让我知道这何时有效,以及您是否需要一些关于如何使用 Geopandas 的好资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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